LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 10-15-2003, 02:54 PM   #1
frankieboy
LQ Newbie
 
Registered: Aug 2003
Location: Germany/Hessen/Kassel
Distribution: RedHat 9.0A
Posts: 11

Rep: Reputation: 0
Question Strange behavior of tar


Hello forum,

I write a short script which automates some backup-jobs. I describe my problem by an example.

find /etc -print > /tmp/backup.list

gives me a list of all files to back up (I want to perform incremental backups using the option -mtime -1).
Then I pack them into an tar.bz2 with the following command:

tar -cjv -T /tmp/backup.list -f backup.tar.bz2

If I look over the resulting archive I realize that the directories below /etc are stored twice in the archive. The next directorylevel is stored three times, so that

tar -tjf backup.tar.bz2|grep XF86Config

shows this file three times.

In /tmp/backup.list every file is present just one time!

In this case I'm really helpless and need your kindly advice.

Frank Becker
 
Old 10-15-2003, 04:12 PM   #2
dorian33
Member
 
Registered: Jan 2003
Location: Poland, Warsaw
Distribution: LFS, Gentoo
Posts: 587

Rep: Reputation: 32
Everything is OK. If you tar /xxx all the files and directories will be tared. Next you add /xxx/yyy so you make additional backup for subdir
 
Old 10-15-2003, 04:33 PM   #3
jrmann1999
Member
 
Registered: Feb 2001
Location: Texas
Distribution: Slackware, Mandrake, LFS
Posts: 306

Rep: Reputation: 30
Thanks to dorian above, he's right. Tar is seeing directory names like /etc/X11 and tarring the whole thing, then it's tarring the individual files within that directory. Just use:

tar -cjvf backup.tar.bz2 /etc

tar is smart enough to recurse subdirectories automatically and add files there.

You could still use your find /etc -print > backup.list for verification of archives.

Last edited by jrmann1999; 10-15-2003 at 04:34 PM.
 
Old 10-16-2003, 03:31 AM   #4
frankieboy
LQ Newbie
 
Registered: Aug 2003
Location: Germany/Hessen/Kassel
Distribution: RedHat 9.0A
Posts: 11

Original Poster
Rep: Reputation: 0
Thanks jrmann,

now I know why there are duplicate entries in the tar-archive.

But, do you have any solution to perform incremental backups with find/tar? I don't want to save the complete directory with all files if there is any file to backup. In this case, if there are any changes in /etc/X11/XF86Config I just want to backup the entiere file and not the whole directory.

Thanks for your help

Frank
 
Old 10-16-2003, 01:53 PM   #5
jrmann1999
Member
 
Registered: Feb 2001
Location: Texas
Distribution: Slackware, Mandrake, LFS
Posts: 306

Rep: Reputation: 30
Your best bet would be to use rsync, it has an incremental backup mode and checks a variety of conditions based on whatever you specify(hint, man rsync). You could create a folder that you would purge->rsync->tar daily for incremental backups of a non-critical nature. There are many well documented solutions involving rsync(and tar if you choose to go that route) if you just google a bit.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
strange directory behavior exodist Linux - Software 1 11-20-2005 04:37 PM
Postfix strange behavior enroth Linux - Networking 2 09-07-2004 12:23 AM
Very Strange Behavior raysr Mandriva 4 08-31-2004 02:06 PM
Strange Behavior andrewb758 Linux - Hardware 5 08-31-2003 02:42 PM
strange behavior abhijit Linux - General 3 07-09-2003 11:25 PM


All times are GMT -5. The time now is 07:42 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration