Change to the directory that contains the files you want to copy.
Insert a tape that is not write-protected into the tape drive.
Copy the files to a tape.
$ ls | cpio -oc > /dev/rmt/n |
ls |
Provides the cpio command with a list of file names. |
cpio -oc |
Specifies that the cpio command should operate in copy-out mode (-o) and write header information in ASCII character format (-c). This option ensures portability to other vendor's systems. |
> /dev/rmt/n |
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 are copied to tape.
$ cpio -civt < /dev/rmt/n |
Remove the tape from the drive and 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 92 blocks $ cpio -civt < /dev/rmt/0 -rw------t 1 kryten users 400 Jul 14 09:28 2001, b drwx--x--x 2 kryten users 0 Jul 14 09:26 2001, letters -rw------t 1 kryten users 10000 Jul 14 09:26 2001, letter1 -rw------t 1 kryten users 10100 Jul 14 09:26 2001, letter2 -rw------t 1 kryten users 11100 Jul 14 09:27 2001, letter3 -rw------t 1 kryten users 12300 Jul 14 09:27 2001, letter4 drwx--x--x 2 kryten users 0 Jul 14 09:27 2001, memos -rw------t 1 kryten users 400 Jul 14 09:28 2001, memosmemoU -rw------t 1 kryten users 500 Jul 14 09:28 2001, memosmemoW -rw------t 1 kryten users 100 Jul 14 09:27 2001, memosmemoX -rw------t 1 kryten users 200 Jul 14 09:28 2001, memosmemoY -rw------t 1 kryten users 150 Jul 14 09:28 2001, memosmemoZ drwx--x--x 2 kryten users 0 Jul 14 09:24 2001, reports 92 blocks $ |
Listing the table of contents takes a long time because the cpio command must process the entire archive.
Insert an archive tape into the tape drive.
$ cpio -civt < /dev/rmt/n |
-c |
Specifies that the cpio command should read files in ASCII character format. |
-i |
Specifies that the cpio command should operate in copy-in mode even though it's only listing files at this point. |
-v |
Displays the output in a format that is similar to the output from the ls -l command. |
-t |
Lists the table of contents for the files on the tape in the tape drive that you specify. |
< /dev/rmt/n |
Specifies the input file of an existing cpio archive. |
The following example shows how to list the files on the tape in drive 0.
$ cpio -civt < /dev/rmt/0 drwx--x--x 2 kryten users 0 Jul 14 09:34 2001, answers -rw------t 1 kryten users 800 Jul 14 09:36 2001, b drwx--x--x 2 kryten users 0 Jul 14 09:32 2001, sc.directives -rw------t 1 kryten users 200000 Jul 14 09:35 2001, direct241 drwx--x--x 2 kryten users 0 Jul 14 09:32 2001, tests -rw------t 1 kryten users 800 Jul 14 09:36 2001, test13times 396 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 |
-i |
Extracts files from standard input. |
-c |
Specifies that cpio should read files in ASCII character format. |
-v |
Displays the files as they are retrieved in a format that is similar to the output from the ls command. |
-d |
Creates directories as needed. |
< /dev/rmt/n |
Specifies the output file. |
Verify that the files are 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 |
-i |
Extracts files from standard input. |
-c |
Specifies that the cpio command should read headers in ASCII character format. |
-v |
Displays the files as they are retrieved in a format that is similar to the output from the ls command. |
"*file" |
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. |
< /dev/rmt/n |
Specifies the input file. |
For more information, see cpio(1).
Verify that the files are 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 |