Showing posts with label tar. Show all posts
Showing posts with label tar. Show all posts

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.

Wednesday, May 7, 2008

Creation of Tar and Compressed file (Tar-ball) in one go

Suppose you want to create tar ball of directory xyz in your home directory.

$ cd ~

$ tar -zcvf xyz.tar.gz xyz/

or

$ tar -jcvf xyz.tar.bz2 xyz/

If you want to untar an unzip at one go, go to
the desired output directory.

$ cd ~

$ tar -zxvf xyz.tar.gz

or

$ tar -jxvf xyz.tar.bz2