[Next] [Previous] [Up] [Top] [Contents]

16.3 Backup and Restore Commands

16.3.5 Tape Archive program, tar

The tape archive program, tar, can be used to copy files to and from tape or across a network. If you're working with individual files or directories you'll probably want to use tar for this service. Most UNIX systems have tar so it's convenient for moving files between different systems. UNIX source archives, e.g. those on archive.cis and many other places, are often stored as compressed tar files. Compression generally saves 1/2 - 2/3 of the original file space. A compressed tar file usually has a name similar to filename.tar.Z, where the "Z" stands for Lempel-Ziv compression. The GNU compression program, gzip, uses a different compression scheme, signified by ending the filename with "z" or "gz". A compressed file is a binary file.

To generate a tar file:

# tar -cvf filename.tar list-of-files

This puts the files into tar format and stores them in filename.tar.

You could just as easily put them onto tape, e.g.:

# tar -cvf /dev/rmt8 list-of-files

Some of the options for tar are:

c - create a new tarfile.

v - verbose, print out the file names as they are archived.

f - use the next argument as the output file.

t - list the files

You can extract files from tape or a tarfile with:

# tar -xvf /dev/rmt8

So if you have a compressed tarfile you would first use uncompress to uncompress the tarfile, then tar with the "-x" option on the tarfile to extract the programs and directories, similar to:

# uncompress filename.tar.Z - which produces "filename.tar" as output.

# tar -xvf filename.tar - which extracts the files, e.g.
filename/Makefile
README
main.c
header.h
...


Unix System Administration - 8 AUG 1996
[Next] [Previous] [Up] [Top] [Contents]