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:
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.
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
The o option (copy out) reads the standard input to obtain a list of path names and copies those files onto the standard output.
The i option (copy in) extracts files from the standard input.
The c option indicates that header information has been written in ASCII format for portability.
The d option indicates that as many directories as needed will be created.
The B option, which you must use whenever you copy files or files systems to and from a tape drive, indicates that the input has a blocking factor of 5120 bytes to the record.
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.
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# dd if=/dev/dsk/c0t0d0s7 of=/dev/rmt/0 bs=96k
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.
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
The 0 (zero) option represents the dump level. A level 0 dump copies the entire file system to a dump file (tape drive). Valid integers are 0 through 9, where 1 through 9 perform various levels of incremental dumps and would only copy files that have changed from a certain time.
The u option updates the dump record by adding a time-stamped entry to the /etc/dumpdates file for each file system that is successfully copied.
The b option specifies the blocking factor that is used when the files are copied to the tape. The b option must be followed by a number (96 in this case) that represents your desired blocking factor. The default blocking factor varies depending on the type of tape drive that you use. If you don't know what blocking factor to use, do not specify one and the default value for your tape drive will work.
The f option specifies the dump file (logical device name of the tape drive). The f option must be followed by a file name, which is /dev/rmt/1 in this example.
/dev/rdsk/c0t1d0s0 is the name of the source that contains the files that you want to write to tape. In this example, all the files will be copied from the first partition (s0) of the second disk drive (t1).
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:
i (interactive) - After reading the directory information from the media, ufsrestore invokes an interactive interface that allows you to browse through the dump file's directory hierarchy and select individual files to be extracted.
r (recursive) - Restore the entire contents of the media into the current directory (which should be the top level of the file system). To completely restore a file system, use this option to restore the level 0 dump, and again for each incremental dump. Although, this option is intended for a complete restore onto a clear file system, if the file system contains files not on the media, they are preserved.
t (table of contents) - Provides a list of every file on a tape.
The following options are not mandatory:
b (blocking factor) - Specify the blocking factor for tape reads. This option must be followed by an integer. By default, the ufsrestore command attempts to determine the correct blocking factor to use.
f (dump file) - Specify the dump file to restore from. ufsrestore will use /dev/rmt/0 if no dump file is specified.
v (verbose mode) - Display path names as they are read from the tape.
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.
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
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.