Apr 2, 2010

Backup Using TAR Command

TAR Backup


The tar program is a utility originally designed for making magnetic tape backups, but is useful for any kind of archiving purpose.

Red Hat Linux includes the GNU version of tar. It includes some extensions to the older standard versions of tar, including multivolume archiving.

Multi-volume archiving is an automated process in which tar prompts for new media to be inserted whenever it runs out of space.

Syntax:

tar –cvf [destination] [source]


Note: Copying files to a tape using the ‘c’ option to tar destroys any files already on the tape. If you want to preserve the files already on the tape, use the ‘r’ option described in "Appending Files to a Tape (tar)" later.

TAR OPTIONS
Command Explanation
A Append the contents of the given tar files to the specified tar archive.
C Create a new tar archive and add the given files to it. Overwrite an existing tar archive. To append files use r or A.
D Find differences between what’s in the tar archive and what’s in the file system.
R Append the given files to the specified tar archive.
T List the contents of the specified tar archive.
U Append the given files to the specified tar archive, but only if they are newer than the files in the tar archive.
X Extract the given files from the specified tar archive.


Examples for tar backup

• tar -cf /dev/st0 /home

Creates an archive of all files under /home on the SCSI tape drive /dev/st0.

• tar –cvf /backup/home.tar /home

Creates an archive of all files under /home on the /backup directory with the name of home.tar.

• tar –xvf /backup/home.tar

Extracts the entire archive stored in the file /backup/home.tar into the current directory.

• tar -czWf /backup/home.tar.gz /home

Creates a gzipped archive file named home.tar.gz in the /backup directory. After writing the archive, tar verifies it.

• tar -zxvf /backup/home.tar.gz

Extracts the entire archive stored in the file /tmp/images.tar.bz2 into the current directory

1 comment:

Lisa said...

thank you for your clear summary of tar