Sunday, February 1, 2009

Backup selected files only

* Difficulty: Intermediate
* Application: tar

Want to use tar to backup only certain files in a directory? Then you'll want to use the -T flag as follows. First, create a file with the file you want to backup:

cat >> /etc/backup.conf
# /etc/passwd
# /etc/shadow
# /etc/yp.conf
# /etc/sysctl.conf
EOF

Then run tar with the -T flag pointing to the file just created:

tar -cjf bck-etc-`date +%Y-%m-%d`.tar.bz2 -T /etc/backup.conf

Now you have your backup.

source: http://www.linuxformat.co.uk/wiki/index.php/58_Cool_Hacks

No comments:

Blog Archive