Change to the directory that contains the files you want to copy.
Insert a write-enabled tape into the tape drive.
Copy the files to tape.
$ ls | cpio -oc > /dev/rmt/n |
Provides the cpio command with a list of file names.
Specifies that the cpio command should operate in copy-out mode (-o) and write header information in ASCII character format (-c). These options ensure portability to other vendors' systems.
Specifies the output file.
All files in the directory are copied to the tape in the drive you specify, overwriting any existing files on the tape. The total number of blocks that are copied is shown.
Verify that the files have been copied to tape.
$ cpio -civt < /dev/rmt/n |
Specifies that the cpio command should read files in ASCII character format.
Specifies that the cpio command should operate in copy-in mode, even though the command is only listing files at this point.
Displays the output in a format that is similar to the output from the ls -l command.
Lists the table of contents for the files on the tape in the tape drive that you specify.
Specifies the input file of an existing cpio archive.
Remove the tape from the drive. Write the names of the files on the tape label.
The following example shows how to copy all of the files in the /export/home/kryten directory to the tape in tape drive 0.
$ cd /export/home/kryten $ ls | cpio -oc > /dev/rmt/0 16 blocks $ cpio -civt < /dev/rmt/0 -rw-r--r-- 1 root other 0 Jul 28 14:59 2004, filea -rw-r--r-- 1 root other 0 Jul 28 14:59 2004, fileb -rw-r--r-- 1 root other 0 Jul 28 14:59 2004, filec drwxr-xr-x 2 root other 0 Jul 28 14:59 2004, letters drwxr-xr-x 2 root other 0 Jul 28 15:00 2004, reports 16 blocks $ |
Listing the table of contents on a tape takes a long time because the cpio command must process the entire archive.
The following example shows how to list the files on the tape in drive 0.
$ cpio -civt < /dev/rmt/0 -rw-r--r-- 1 root other 0 Jul 28 14:59 2004, filea -rw-r--r-- 1 root other 0 Jul 28 14:59 2004, fileb -rw-r--r-- 1 root other 0 Jul 28 14:59 2004, filec drwxr-xr-x 2 root other 0 Jul 28 14:59 2004, letters drwxr-xr-x 2 root other 0 Jul 28 15:00 2004, reports 16 blocks $ |
If the archive was created using relative path names, the input files are built as a directory within the current directory when you retrieve the files. If, however, the archive was created with absolute path names, the same absolute paths are used to re-create the file on your system.
The use of absolute path names can be dangerous because you might overwrite existing files on your system.
Change to the directory where you want to put the files.
Insert the tape into the tape drive.
Extract all files from the tape.
$ cpio -icvd < /dev/rmt/n |
Extracts files from standard input.
Specifies that the cpio command should read files in ASCII character format.
Displays the files as they are retrieved in a format that is similar to the output from the ls command.
Creates directories as needed.
Specifies the output file.
Verify that the files were copied.
$ ls -l |
The following example shows how to retrieve all files from the tape in drive 0.
$ cd /var/tmp cpio -icvd < /dev/rmt/0 answers sc.directives tests 8 blocks $ ls -l |
Change to the directory where you want to put the files.
Insert the tape into the tape drive.
Retrieve a subset of files from the tape.
$ cpio -icv "*file" < /dev/rmt/n |
Extracts files from standard input.
Specifies that the cpio command should read headers in ASCII character format.
Displays the files as they are retrieved in a format that is similar to the output from the ls command.
Specifies that all files that match the pattern are copied to the current directory. You can specify multiple patterns, but each pattern must be enclosed in double quotation marks.
Specifies the input file.
For more information, see the cpio(1) man page.
Verify that the files were copied.
$ ls -l |
The following example shows how to retrieve all files with the chapter suffix from the tape in drive 0.
$ cd /home/smith/Book $ cpio -icv "*chapter" < /dev/rmt/0 Boot.chapter Directory.chapter Install.chapter Intro.chapter 31 blocks $ ls -l |