As we said in article 20.2 , making a backup is easy:
The cd command moves you to your home directory. You could back up any directory the same way.
You might get an error. Something about device rmt8 off line. Don't worry. I exaggerated slightly when I said tar was easy to use. The tape device that SunOS tar uses by default is /dev/rmt8 (yours may be different). There are several types of tape units, and not all can be referred to using that name. Some system administrators will link that name to the actual device, which makes tar easier to use. But if that doesn't work, you need to specify additional arguments to tar .
Most UNIX commands follow a certain style when arguments are specified. tar does not follow this convention, so you must be careful to use tar properly. If the standard was followed, then the following might be an example of dumping the current directory to the 1/2-inch tape cartridge, verbose mode, block size of 20:
Instead, all the flags are in the first argument, and the parameters to those flags follow the first argument, in order of the flags specified:
The same command can be specified in a different way by changing the order of the letters in the first argument:
(Article 20.11 has diagrams and more information about the order of arguments.) The only key letter that has a fixed location is the first one, which must specify if you are reading or writing an archive. The most common key letters, and the functions they perform are listed in Table 20.1 .
Some versions of
require a hyphen (
Part of the difficulty in using tar is figuring out which filename to use for which device. The best way to find out is by asking your system administrator. If you can't, here are some ideas for Sun computers. If you have a 1/2-inch tape drive, try:
If you have a 1/4-inch tape cartridge [or any drive connected by SCSI -JP ], try:
If this doesn't work, then try changing the
Some UNIX systems use different standards for naming magnetic tapes. There might be an h at the end of a name for high density . When in doubt, examine the (using the ls -l command) and read the appropriate manual page, which can be found by searching through the possible entries using :
The names of tape devices typically start with an r , which suggests they are raw devices that do not support a filesystem. If the first two letters are nr , then this suggests a no-rewind operation. Normally the tape is automatically rewound when you are done. If you repeat the tar command, it will overwrite the first dump.  As this can waste large amounts of tape if the dumps are small, use the nr name of the tape to put several dumps on one tape. As an example, if you wanted to dump three separate directories to a 1/4-inch tape cartridge, you can type:
Note that the third dump does not use the no-rewind name of the device, so that it will rewind when done.
To examine a tape without extracting any files,
get a table of contents and use the key letter
If you want to examine the third dump file, you can either use tar twice with the no-rewind names or skip forward one or more dump files by using the mt (magnetic tape) command to skip forward two. Be sure to use the no-rewind name:
In some versions of tar , if you defined an environment variable TAPE :
setenv TAPE /dev/rst8
then you don't have to specify it for the mt or tar commands.