Monday, June 2, 2008

Backup Using TAR

Tar utility can be used to take backup. I have created a
handy script to do backup of files/directories(mentioned in
tar_include.txt).

# vi my_backup.sh

1 out_file=/mnt/Backup/backup_`date +20%y%m%d`.tar.gz

2
3 echo "Creating $out_file ..."
4
5 tar -zcpvf $out_file -T tar_include.txt -X tar_exclude.txt
6
7 sync
8 echo "Completed Backing up"

# vi tar_include.txt
1 /home/mitesh/.purple/
2 /home/mitesh/.thunderbird/
3 /home/mitesh/Programming/
4 /home/mitesh/Documents/
...
...

You can exclude files/directories inside those
mentioned in tar_include.txt. Just you have to
write files/directories in tar_exlcude.txt .
# vi tar_exclude.txt
1 /home/mitesh/Programming/Perl/Modules/*
2 /home/mitesh/Documents/CrawlDoxy/*
...
...

Now run the above shell script to get backup with
date in /mnt/Backup/ .

Note: You can take regular backups using above scipt too.
Just you have to give interval and path of above script
in /etc/crontab file.

No comments: