The tar command archives and retrieves files to and from a single file called a tarfile. A tarfile is usually a tape, but it can be any file. If the amount of data exceeds one tape then you need to use a different tape command because tar cannot span multiple volumes (tapes).
Example 1:
The following example shows how to copy files from a hard disk to a tape.
example# tar cvbf 96 /dev/rmt/1 ./directory
In this example, the tar command copies files from a directory to a tape drive with the device name of /dev/rmt/1. Specifying the directory source preceded with a ./ will cause the files to be recorded as relative path names. Later, when the files are extracted, they files will be written back into the file system based on your current working directory.
The c option creates the tarfile (writes to tape in this case).
The v option displays information about each file it copies (verbose mode).
The b option designates the blocking factor, which in this example is 96.
The f option designates the device name of the source drive, which is the tape drive in this example.
Example 2:
The next example shows how to copy files from a tape to the current working directory on a hard disk. It is very important to change to the directory where the extracted files will reside before running tar.
example# cd /tmp example# tar xvbf 96 /dev/rmt/1
The x option extracts files from the tarfile (tape).
The v option displays information about each file it is extracted (verbose mode).
The b option designates the blocking factor, which in this example is 96.
The f option allows you to designate the dump file of the destination drive.
You must use the same blocking factor (or larger) when you retrieve or copy files from the tape to the hard disk as you did when you copied files from the hard disk to the tape.