Solaris Handbook for Sun Peripherals

Tape Utilities

There are many utilities that are used to read or write data to a tape drive. This section covers some of the common tape utilities that come with the Solaris operating environment. If you have purchased an additional tape or backup utility please refer to that documentation.

The following commands are covered in this section:


Note -

If you have a 5.0 Gbyte 4mm DDS device, use a blocking factor of 96 instead of the default factor of 20 to optimize performance. The blocking factor of 96 translates to 48 Kbytes per transfer. For the 150 Mbyte 1/4-inch tape drive, the 2.3 Gbyte 8mm tape drive, the 5.0 Gbyte 8mm tape drive, and the Front-Load 1/2-inch tape drive, use a blocking factor of 126 instead of the default factor of 20 to optimize performance. Blocking factors are specified as options on the command line of the tape utility command that you choose to use.


cpio Command

The cpio command (copy in/out) copies a list of files between devices by taking a list of names from standard input and writing to standard output. It is a versatile command but requires you to redirect standard-in and standard-out. cpio can be used when the amount of data requires the use of more that one volume (tape cartridge).

Example 1:

The following example shows how to copy the files in your working directory called /work and all subdirectories to the first tape drive with the logical device name of /dev/rmt/0.


example# cd /work
example# ls -R | cpio -ocB > /dev/rmt/0

Example 2:

The next example shows how to copy the files that are located on your tape back to your hard disk:


example# cd /work
example# cpio -icdB < /dev/rmt/0


Note -

You must use the same blocking factor 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. In such cases you must specify the B option.


dd Command

This command converts and copies files with different data formats. One usage of this command is to transfer a file system or partition from your hard disk to a tape. You can also use it to copy files from one hard disk to another. If you use a device with a variable block size, you need to make sure that you use the same block size when you retrieve the data.

The following example shows how to write the file system or partition /user/sunsystem to a 4mm tape drive with a tape drive called /dev/rmt/0. The blocking factor is 96 in this example. This example has been optimized for a 5.0 Gbyte 4mm DDS device.

Example:


example# dd if=/dev/dsk/c0t0d0s7 of=/dev/rmt/0 bs=96k

ufsdump Command

The ufsdump command copies a file system or directory from a hard disk to a tape. It is specifically designed as a backup utility. It supports multiple volumes, and incremental backups. For more information about incremental dump levels and schedules, see the System Administration Guide.


Note -

All files must be part of one file system or one partition and you must be superuser.


Example:

The following example shows how to copy all files that are located on a disk drive in partition /dev/rdsk/c0t3d0s0 to a dump file (that represents the tape drive in this case) called /dev/rmt/1.


example# ufsdump 0ubf 96 /dev/rmt/1 /dev/rdsk/c0t1d0s0

ufsrestore Command

The ufsrestore command copies file systems from a tape to a hard disk. It can only copy file systems that were created with the ufsdump command.

You must use ufsrestore with one of these three options:

The following options are not mandatory:

Example:

The following example shows how to retrieve a file from tape interactively. The file will be written in the current directory (/disk2 in this example). A blocking factor of 96 is specified as well as the dump file (first tape drive) of /dev/rmt/0.


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.



example# cd /disk2
example# ufsrestore ibf 96 /dev/rmt/0
ufsrestore > ?
Available commands are:
  ls [arg] - list directory
  cd arg - change directory
  pwd - print current directory
  add [arg] - add `arg' to list of files to be extracted
  delete [arg] - delete `arg' from list of files to be
extracted
  extract - extract requested files
  setmodes - set modes of requested directories
  quit - immediately exit program
  what - list dump header information
  verbose - toggle verbose flag (useful with "ls")
  help or `?' - print this list
IF no `arg' is supplied, the current directory is used

The system responds with a ufsrestore prompt. If you type a question mark, a list of available arguments is displayed.

List the directories that are resident on the tape by typing ls.


ufsrestore > ls
4lib/     dict        mail    openwin      spool
5bin      games       man/    preserve     src
adm       include/    net     pub          tmp

Now add the files or directories to the list of files to extract with the add command:


ufsrestore > add man mail

In this example the man and mail files are added to the list of files to extract from tape.

Now extract these files from the tape. They will be written to your current working directory (/disk2 in this example).


ufsrestore > extract

Once all the desired files are extracted, exit the ufsrestore command with q:


ufsrestore > q

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.