Backtrack:  
 
by lunarg on August 17th 2007, at 15:20

This little article contains some useful tips and tricks about using tar.

Backup directories from /

When your starting point for the tar is situated at /, you may already have noticed the warning output from it:

Quote
tar: Removing leading `/' from member names

In case of an automated backup, where the tar is executed using cron, this warning quickly becomes annoying: most systems mail the output of a cron job to a specified email address (and in any normal scenario, this is configured properly to know whether a backup succeeds or fails). If each time you get a mail with only this warning (the rest of the backup was succesfully completed), one might actually lean towards suffering from a nervous breakdown (if only for receiving the useless mail every once in a while).

A trick to circumvent it, and kick out the warning, is by constructing your tar command line like so:

tar -C / -cjf /srv/data/backup/etc.tar.bz2 etc/

This tells tar to cd to the / first, before starting the archive process. You could rewrite the command above like so:

cd / && tar -cjf /srv/data/backup/etc.tar.bz2 etc/

But then, if you need to return to the directory you were in, that would require some more programming.

 
 
« November 2024»
SunMonTueWedThuFriSat
     12
3456789
10111213141516
17181920212223
24252627282930
 
Links
 
Quote
« I needed a password with eight characters so I picked Snow White and the Seven Dwarves. »