[EdCert previous] [EdCert next] [EdCert top]

Making Backups and Restoring

Accessing the Tape Drive

Because Unix treats everything as a file, accessing the tape drive to perform a backup means accessing the tape special file. Tape drives are almost always accessed in character or raw mode. The device files for tape drives usually have names that follow the form /dev/rmt/n. n indicates the number of the drive. It may be followed by other characters which dictate the way the drive is accessed. These other characters include the density, whether or not compression is used, whether or not the tape is rewound, etc.

Below is table of tape device file naming conventions for the first tape drive on a system. A text version of this table is also available.

System SCSI ID Rewinding Non-rewinding
SunOS 4 /dev/rst0 /dev/nrst0
Solaris 4 /dev/rmt/0 /dev/rmt/0n
IRIX 3 /dev/rmt/tpsod3
HP-UX 9.X 3 /dev/rmt/c201d3m
HP-UX 10.X 3 /dev/rmt/clt3d0BESTb
0mb or 0m
0mnb or 0mn
Linux N/A /dev/st0 /dev/nst0

Making a Table of Contents

Most backup utilities create a list on the tape of which files or filesystems the tape contains. This is not always the most convenient way to locate a file, as it requires checking tapes until the right file is found. An option is to create an online table of contents file that lists the contents of each backup tape.

With tar and cpio this can be done using the v option. When using dump and restore, after a dump is complete restore tvf will write a table of contents to a selected file.

Putting Several Backups on One Tape

It's not always necessary to keep a tape for each archive. Some utilities allow several archives to be written to one tape. When writing multiple archives, the tape needs to be rewound before the first archive is written. For all subsequent archives a non-rewinding device should be used.

When extracting a file from a tape with several archives, the tape must in the proper position before issuing the command to retrieve the file. This can be done with mt or with restore -s.

Basic Utilities

There are a number of basic Unix utilities available for creating backups as well as vendor specific packages. Backup utilities come in two basic types; filesystem oriented and file oriented. Filesystem oriented backup utilities are meant to be used for backing up entire filesystems, although some can be used to back up individual files and directories. File oriented backup utilities are intended for backing up files and directories. Some of these utilities can be used for backups of entire filesystems. Most of these utilities provide some means of compressing data. Compression involves using an algorithm to compress or repack the data so that it takes up less space. It is commonly used on packages available via ftp because compressed data takes less time to transfer. In terms of backups, compression allows more information to be stored on the media. Some tape devices provide a hardware compression mechanism which defeats the purpose of compression done by a utility. A chart of which utilities are offered on which platforms is available as a table or in text form.

Please note that the included man pages were taken from several different systems and the specifics may differ from system to system.


tar, the tape archiver, and cpio, copy file archives in and out, are both file oriented utilities. tar can be used to copy files across a network as well as create file or tape archives of files, directories and directory trees.It can also be used to restore files from a tape. The basic functionalities it provides include:

The basic syntax of the tar command is tar followed by options, option modifiers, name of files or directories to be archived, block size and the device name for the archive on the tape. For specifics on appropriate block sizes and how options are used, it is best to consult the man page because these differ from vendor to vendor.The basic tar utility is a standard part of IRIX, HP-UX, Solaris and other Unix operating systems. There is a GNU version of tar that supports additional functionalities. It is included in Linux distributions.

tar can be used with the find command to create incremental backups. find can be used to locate files which have been modified within a specified number of days. tar can then be used to backup these files. Find can also be used to exclude directories so that tar will not archive them.

Some advantages and disadvantages of the basic tar command include:


cpio is included in standard distributions of IRIX, HP-UX, Solaris, Linux and other Unix operating systems. It can be used to backup multiple files or directories, a single file or directory, or and entire directory tree. It has this flexibility because it uses standard input and output. cpio receives all its input from another command, such as ls. The output can then be redirected to a backup tape. This makes cpio extremely convenient for small local backups. The three basic options for cpio are -i, -p, and -o. cpio -i extracts files from standard input. cpio -p reads standard input to obtain a list of pathnames of files that are created and copied into a destination directory. cpio -o reads standard input to get a list of pathnames and copies those files to standard output, including the pathname information. The syntax for cpio is as follows:

find /usr -print | cpio -o > /dev/rmt0

This copies all the files in /usr and its subdirectories into the tape in drive 0. Some versions of find support a -cpio option. If this is the case the syntax would be:

find /usr -cpio /dev/rmt0

As with tar, find can be used with cpio to create incremental backups. cpio -i can also be used to restore files.

The advantages and disadvantages of cpio include:

dump and rdump

dump and rdump are available under HP-UX and IRIX. The dump utility dumps all the files in a filesystem, or files modified after a specified date, to a tape or another file. rdump performs the same function, but is used for remote dumps. The syntax is as follows:

dump key arguments filesystem

rdump key arguments filesystem

key is a series of options that specify the date, dump level, etc. If no key the default is 9u. This performs a level nine incremental dump of the selected filesystem, updates /etc/dumpdates, and dumps the filesystem to the default device /dev/tape. arguments can be given for some options. If arguments are included, they are listed after the key in the same order as the options.

dump can be used for incrementals, but is not the best choice for backing up individual files and directories.

restore and rrestore

Like dump, restore and rrestore are available under HP-UX and IRIX. dump and restore work as a pair, restore is used to restore filesystems from tapes created with dump. rrestore is used for remote restorations. The syntax is as follows:

restore key name

rrestore key name

Again key is a series of options, or functions, that can be followed by one or more modifiers. restore and rrestore can be used to restore individual files and directories.


dd is not specifically a backup utility, but it can be used as one. It is available under HP-UX, IRIX, Solaris and Linux. dd copies and converts files so that they may be transferred from one type of media to another. It can process an entire entity or selected blocks. It also has the ability to do byte swapping. dd copies a selected input file to a selected output file. If no input or output file are specified, standard input and output are used by default. dd is probably best used to create a backup by copying the entire contents of one disk or filesystem to another disk. It can also be used to copy files to a remote tape drive.

The syntax of dd is the command followed by arguments which consist of option=value pairs. These options include:

dd is also capable of reading tapes that were written in a format other than Unix.


Like dd, pax is not specifically a backup tool. However, it can be used to copy files from one system to another. pax is more complicated to use than dd, as its syntax is complex. It is available under HP-UX and Solaris 2.5.


mt is available under Solaris, HP-UX, IRIX, and Linux. It is not a backup utility, but a program used to control tape drives. The syntax is:

mt -f device_name command count

If no option is given, whatever operation the command specifies will be performed on the default tape device. The tapename can be the name of a remote tape device. The syntax for specifying a remote device is:


user refers to the login name to be used on the remote system and it is optional. system is the name of the remote system and /dev/??? is the drive on the remote system.

command does not refer to standard Unix commands, but to a set of commands that pertain to mt. Among these commands are blksize, which prints the recommended block size, and retension, which retensions the tape. Other commands are listed in the man page. By default, a command is run once. If the command performs an operation which may be run more than once, count is used to set the number of times the operation is performed.

Keeping it Clean

A couple things that can cause read/write tape errors are dirt and tape slack. Tape drives should be cleaned according to the manufacturers recommendations. They may need to be cleaned more often when using new tapes. Retensioning will eliminate any slack in a tape. It equalizes the tension on the tape by moving to the beginning of the tape, then to the end and rewinding it back to the beginning.

Operating System Specifics

For information on vendor specific backup utilities, tips and quirks:

Terms used:archive.

[EdCert previous] [EdCert next] [EdCert top]