Solaris Handbook for Sun Peripherals

tar Command

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.

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


Note -

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.