Previous Table of Contents Next


Retrieving All Files from a Tape (cpio)

If the archive was created using relative path names, the input files are built as a directory within the current directory. If, however, the archive was created with absolute path names, the same absolute paths are used to re-create the file.


CAUTION! Using absolute path names can be dangerous because you can overwrite the original files.

Follow these steps to retrieve all 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 cpio -icv < /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% cpio -icv < /dev/rmt/Ø
Boot.chapter
Directory.chapter
Install.chapter
Intro.chapter
31 blocks
oak%

Retrieving a Subset of Files from a Tape (cpio)

You can retrieve a subset of the files from the archive by specifying a pattern to match using shell wildcard characters enclosed in quotation marks after the options:

1.  Change to the directory where you want to put the files.
2.  Insert the tape into the tape drive.
3.  Type cpio -icv "* file " < /dev/rmt/n and press Return. All the files that match the pattern are copied to the current directory. You can specify multiple patterns, but each must be enclosed in quotation marks.

In this example, all files that end in the suffix chapter are copied from the tape in drive 0:

oak% cd /home/winsor/Book
oak% cpio -icv "*chapter" < /dev/rmt/Ø
Boot.chapter
Directory.chapter
Install.chapter
Intro.chapter
31 blocks
oak%

See the cpio(1) manual page for more information.

The pax Command

The 2.5 release and later provide the pax command, which stands for portable archive interchange. The pax command provides better portability than the tar or cpio commands for POSIX-compliant systems. Use the pax command to copy files, special files, or file systems that require multiple tape volumes or when you want to copy files to and from POSIX-compliant systems. Disadvantages of the pax command are that it is not aware of file system boundaries and the full path name length cannot exceed 255 characters.

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

Follow these steps to use the pax command to copy all the files in the current directory to a tape:

1.  Change to the directory that contains the files you want to copy.
2.  Insert a write-enabled tape into the tape drive.
3.  Type pax -w -f </dev/rmt/n. and press Return. The -w option writes the current directory contents to tape. The -f option identifies the tape drive. The pax command does not list the files as they are copied.
4.  Type pax -l -f </dev/rmt/n and press Return. The -l option lists the files on the tape to verify that the files are copied.
5.  Remove the tape from the drive and write the names of the files on the tape label.

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

castle% pax -w -f /dev/rmt/0 .
castle% pax -l -f /dev/rmt/0
.
./addusr-1.rs
./addusr-2.rs
./at-addmn.rs
./at-base.rs
./at-menu.rs
castle%

See the pax(1) manual page for more information.


NOTE:  When you use the pax command to copy files to a single-volume tape, you can also list and retrieve files from that tape by using the tar command.

Retrieving All Files on a Tape (pax)

Follow these steps to use the pax command to copy all the files on a tape into the current directory:

1.  Change to the directory where you want to copy the files.
2.  Insert a write-enabled tape into the tape drive.
3.  Type pax -r -f </dev/rmt/n . and press Return. The -r option reads the contents of the tape to the current directory. The -f option identifies the tape drive. The pax command does not list the files as they are copied.
4.  Type ls -l and press Return. The ls -l command lists the files in the current directory and shows their permissions to verify that the files are copied.
5.  Remove the tape from the drive and write the names of the files on the tape label.

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

castle% pax -r -f /dev/rmt/0 .
pax: . :not owner
castle% ls -l
-rw-rw-rw-   1 winsor   staff     245660 Sep 12 11:52 addusr-1.rs
-rw-rw-rw-   1 winsor   staff     245660 Sep 12 10:31 addusr-2.rs
-rw-rw-rw-   1 winsor   staff     181315 Sep 12 10:29 at-addmn.rs
-rw-rw-rw-   1 winsor   staff     181309 Sep 12 10:27 at-base.rs
-rw-rw-rw-   1 winsor   staff     181315 Sep 12 10:28 at-menu.rs
castle%


Previous Table of Contents Next