[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: tar syntax and backing up



Le dimanche 18 mars 2007 17:14, Tyler Smith a écrit :
> Hi,
>
> Related to another post concerning the possible demise of my
> harddrive, I thought I'd better confirm with wiser people that my
> backup plan is doing what I think it's doing.
>
> I've got a full backup of all my important data in tar.gz files on my
> harddrive and burned onto cds. I want to backup everything that has
> been modified since the last full backup, so I use:
>
> tar --newer-mtime ../mail4Mar07.tar.gz -cvzf 18Mar2007.tar.gz \
>  /home/tyler/bibtex/ /home/tyler/thesis/ /home/tyler/analysis/ \
>  /home/tyler/grassdata/ /home/tyler/Mail/
>
> As far as I can tell from the output and tar -t this is correct, but
> I'd hate to find out after my drive dies that I'm mistaken...
>

I'd rather suggest to use incremental backups, because they also check for 
other metadatas (file size, dev inode...) as the date is not always enough, 
and also because they will remove deleted files when restoring (I don't think 
newer-mtime does it, but I never used it so I may be wrong). To do it, choose 
a location to store snapshot files and:

# do a level 0 (full dump)
rm -f snapshot0
tar --listed-incremental=snapshot0 -czf dump0.tar.gz ...

# do a level 1
cp -f snapshot0 snapshot1
tar --listed-incremental=snapshot1 -czf dump1.tar.gz ...

# do a level 2
cp -f snapshot1 snapshot2
tar --listed-incremental=snapshot2 -czf dump2.tar.gz ...

# ...

And to restore:
tar --listed-incremental=/dev/null -xzf dump0.tar.gz
tar --listed-incremental=/dev/null -xzf dump1.tar.gz
tar --listed-incremental=/dev/null -xzf dump2.tar.gz

There are many backup tools which can do this for you, I personnaly choose 
Amanda because it has a good estimation feature to decide automatically which 
level should be done, but there are probably many other good choices.
If you want to do it by hand anyway, also read the tar docs for some useful 
parameters, like --preserve-permissions, --numeric-owner and things like 
that. The funny thing about tar is that some docs are in the man page but not 
in the info and vice versa, so it's probably a good idea to read them both.

Enjoy :)
-- 
Cédric Lucantis



Reply to: