LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-04-2009, 08:19 AM   #1
nny0000
Member
 
Registered: Aug 2003
Distribution: Slackware, Ubuntu
Posts: 158

Rep: Reputation: 30
Getting tar to save files correctly?


I am working on a bash script and I am not getting the desired results.

My script is set up as such:
Code:
#!/bin/bash
tar -cjf $BACKUPDIR/folder1-$DATE.tar.bz2 $HOMEDIR/folder1/
tar -cjf $BACKUPDIR/folder2-$DATE.tar.bz2 $HOMEDIR/folder2/
When I run it, I get this error:
Code:
Removing leading `/' from member names
Also, when I open the directory, it saves every parent directory. So it will show /home/me/folder1 instead of only having 'folder1' as the root folder in the archive.

How can I fix this so I don't get this error and tar up the files so 'folder1' and 'folder2' are the root directories?

Thanks!
 
Old 02-04-2009, 08:46 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Code:
Removing leading `/' from member names
"Nothing to see here." That is perfectly normal.

Quote:
it saves every parent directory
Because you ran it from /.

tar -C $HOMEDIR -cjf $BACKUPDIR-<date>.tar.bz folder1

The -C argument will change the working directory. Now the archive will have folder1 as the base.
 
Old 02-04-2009, 08:50 AM   #3
burschik
Member
 
Registered: Jul 2008
Posts: 159

Rep: Reputation: 31
Quote:
Originally Posted by nny0000 View Post
When I run it, I get this error:
Code:
Removing leading `/' from member names
That's not an error.

Quote:
Also, when I open the directory, it saves every parent directory. So it will show /home/me/folder1 instead of only having 'folder1' as the root folder in the archive.
Use the "-C" option to change directories.
 
Old 02-04-2009, 11:03 AM   #4
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
I think you want this:
$HOMEDIR/folder1
instead of this:
$HOMEDIR/folder1/
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
a tough question 4 u, problem in extracting tar & tar.gz files p_garg Linux - General 5 11-08-2010 11:02 AM
Samba server not allowing windows client to save files correctly royce2020 Linux - Server 6 11-07-2007 12:30 PM
tar --newer isn't working correctly. Micro420 Linux - General 3 03-23-2007 05:13 AM
tar -zxvf foo.tar.gz creates all .gz files prophoto Linux - General 11 11-09-2006 06:27 PM
Tar won't correctly restore from incremental backups therealbeale Linux - Software 1 08-31-2006 10:02 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration