Strange behavior of tar
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.
:scratch: Frank Becker
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 :)
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.
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
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.
|All times are GMT -5. The time now is 03:46 AM.|