Previous Table of Contents Next


Retrieving Files and Directories from a Tape (tar)

Follow these steps to retrieve files from a tape:

1.  Change to the directory where you want to put the files.
2.  Insert the tape into the tape drive.
3.  Type tar xvf /dev/rmt/n and press Return. All the files on the tape in the drive you specify are copied to the current directory.

In this example, all files are copied from the tape in drive 0:

oak% cd /home/winsor/Evaluations
oak% tar xvf /dev/rmt/Ø
x evaluation.doc, 44Ø32 bytes, 86 tape blocks
x evaluation.doc.backup, 43ØØ8 bytes, 84 tape blocks
oak%

To retrieve individual files from a tape, type tar xvf /dev/rmt/n filename filename filename ... and press Return. The file names you specify are extracted from the tape and placed in the current working directory. In this example, files with the prefix evaluation are copied from the tape in drive 0:

oak% cd /home/winsor/Evaluations
oak% tar xvf /dev/rmt/0 evaluation*
x evaluation.doc, 44032 bytes, 86 tape blocks
x evaluation.doc.backup, 43008 bytes, 84 tape blocks
oak%

Follow these steps to retrieve directories and subdirectories recursively from a tape:

1.  Change to the parent directory where you want to copy the files. If the directory already exists, be sure you are in the parent directory, and that it is okay to overwrite the contents of the directory before you copy the files from the tape. For example, to restore the contents of a directory named Book that is in /home/winsor/Book, you would change to /home/winsor and type tar xvf /dev/rmt/n Book and press Return. If you are in the directory /home/winsor/Book, the files will be restored as /home/winsor/Book/Book.
2.  Type tar xvf /dev/rmt/n directory-name and press Return. The directory and all its subdirectories are recursively copied from the tape.


NOTE:  The names of the files extracted from the tape exactly match the names of the files stored on the archive. If you have any doubts about the names or paths of the files, first list the files on the tape. See "Listing the Files on a Tape (tar)" earlier for instructions and the tar(1) manual page for more information.

The cpio Command

The cpio command copies files, special files (files used to represent peripheral devices attached to a system), and file systems that require multiple tape volumes, and provides compatibility for copying files from SunOS 5.x systems to SunOS 4.x systems. Advantages of using the cpio command are that it packs data onto tape more efficiently than the tar command, skips over any bad spots in a tape when restoring files, provides options for writing files with different header formats (tar, ustar, crc, odc, bar) for portability between different system types, and creates multiple tape volumes.

When you use the cpio command to create an archive, it takes a list of files or path names from standard input and writes to standard output. The output is almost always redirected to a file or device. The following sections describe how to use the cpio command to copy files to a cartridge tape, list the files, retrieve all files, and retrieve a subset of the files from a cartridge tape.

Copying All Files in a Directory to a Tape (cpio)

Follow these steps to copy all files in a directory to a tape:

1.  Insert a write-enabled tape into the tape drive.
2.  Type ls | cpio -oc > /dev/rmt/n and press Return. The o option copies the files. The c option writes header information in ASCII character form for portability. All the files in the directory are copied to the tape in the drive you specify, overwriting any existing files on the tape, and the total number of blocks copied is displayed.
3.  Remove the tape from the drive and write the names of the files on the tape label.

In this example, all the files in the directory /home/winsor/TOI are copied to the tape in tape drive 0:

oak% cd /home/winsor/TOI
oak% ls | cpio -oc > /dev/rmt/Ø
31 blocks
oak%

Listing the Files on a Tape (cpio)

To list files on a tape:

1.  Insert a tape into the tape drive.
2.  Type cpio -civt < /dev/rmt/n and press Return. The i option reads in the contents of the tape. The v option displays the output in a format similar to the output from the ls -l command. The t option lists the table of contents for the files on the tape in the tape drive you specify.


NOTE:  Listing the table of contents takes as long as it does to read the archive file because the cpio command must process the entire archive.

In this example, the table of contents for the tape in drive 0 contains four files:

oak% cpio -civt < /dev/rmt/Ø
1ØØ666 winsor   3895  Feb 24 15:13:Ø2 1992  Boot.chapter
1ØØ666 winsor   3895  Feb 24 15:13:23 1992  Directory.chapter
1ØØ666 winsor   6491  Feb 24 15:13:52 1992  Install.chapter
1ØØ666 winsor   1299  Feb 24 15:14:ØØ 1992  Intro.chapter
31 blocks
oak%

The first column shows permissions in octal form; the second column shows the owner of the file; the third column displays the number of characters (bytes) in the file; the fourth, fifth, sixth, and seventh columns show the month, date, time, and year the file was last modified; and the final column shows the name of the file.


Previous Table of Contents Next