This section describes how to copy files with the pax command.
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 with the pax command.
$ pax -w -f /dev/rmt/0 filename ... |
-w |
Enables the write mode. |
-f /dev/rmt/0 |
Identifies the tape drive. |
filename ... |
Indicates the files and directories you want to copy. |
Verify the files are copied to tape.
$ pax -f /dev/rmt/0 |
Remove the tape from the drive and write the names of the files on the tape label.
$ pax -w -f /dev/rmt/0 . $ pax -f /dev/rmt/0 filea fileb filec |
See pax(1) for more information.
Insert a tape that is not write-protected into the tape drive.
Copy files to a tape using the ls and cpio commands.
$ ls | cpio -oc > /dev/rmt/n |
ls |
Provides the cpio command with a list of file names. |
cpio -oc |
Specifies that cpio should operate in copy-out mode (-o) and write header information in ASCII character format (-c). This ensures portability to other vendor's systems. |
> /dev/rmt/n |
Specifies the output file. |
All of the 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 copied is displayed.
Verify the files are copied to tape by using the following cpio command.
$ cpio -civt < /dev/rmt/0 |
Remove the tape from the drive and write the names of the files on the tape label.
The following example copies all of the files in the directory /export/home/kryten to the tape in tape drive 0.
$ cd /export/home/kryten $ ls | cpio -oc > /dev/rmt/0 8 blocks $ cpio -civt < /dev/rmt/0 drwxr-xr-x 2 kryten users 0 Jun 9 15:56 1998, letters drwxr-xr-x 2 kryten users 0 Jun 9 15:56 1998, memos drwxr-xr-x 2 kryten users 0 Jun 9 15:55 1998, reports 8 blocks $ |
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.
Insert an archive tape into the tape drive.
List the files on the tape using the cpio command.
$ cpio -civt < /dev/rmt/n |
-c |
Specifies that cpio should read files in ASCII character format. |
-i |
Specifies that cpio should operate in copy-in mode (even though its only listing files at this point). |
-v |
Displays the output in a format 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 you specify. |
< /dev/rmt/n |
Specifies the input file of an existing cpio archive. |
The following example lists the files on the tape in drive 0.
$ cpio -civt < /dev/rmt/0 drwxr-xr-x 2 rimmer users 0 Jun 9 16:07 1998, answers drwxr-xr-x 2 rimmer users 0 Jun 9 16:07 1998, sc.directives drwxr-xr-x 2 rimmer users 0 Jun 9 16:07 1998, tests 8 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 recreate the file on your system.
Using absolute path names can be dangerous because you may overwrite existing files on your system.
Change to the directory where you want to put the files.
Insert the tape into the tape drive.
Copy all files from the tape to the current directory using the cpio command.
$ cpio -icvd < /dev/rmt/n |
-i |
Reads in the contents of the tape. |
-c |
Specifies that cpio should read files in ASCII character format. |
-v |
Displays the files being retrieved in a format similar to the output from the ls command. |
-d |
Create directories as needed. |
< /dev/rmt/n |
Specifies the output file. |
Verify the files are copied by listing the contents of the current directory.
$ ls -l |
The following example retrieves 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 a tape using the cpio command.
$ cpio -icv "*file" < /dev/rmt/n |
-i |
Reads in the contents of the tape. |
-c |
Specifies that cpio should read headers in ASCII character format. |
-v |
Displays the files as they are retrieved in a format similar to the output from the ls command. |
"*file" |
Specifies that all of the files that match the pattern are copied to the current directory. You can specify multiple patterns, but each must be enclosed in double quotation marks. |
< /dev/rmt/n |
Specifies the input file. |
Verify the files are copied by listing the contents of the current directory.
$ ls -l |
The following example retrieves all files with the suffix chapter 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 |
See cpio(1) for more information.
The following prerequisites must be met to use a remote tape drive:
The local hostname (and optionally the username of the user doing the copy) must appear in the remote system's /etc/hosts.equiv file, or the user doing the copy must have his or her home directory accessible on the remote machine, and have the local machine name in $HOME/.rhosts. See hosts.equiv(4) for more information.
An entry for the remote system must be in the local system's /etc/inet/hosts file or in the name service hosts file.
To test whether or not you have the appropriate permission to execute a remote command, try the following.
$ rsh remotehost echo test |
If "test" is echoed back to you, you have permission to execute remote commands. If "Permission denied" is echoed, check your setup as described in step 1 above.
To copy files to a remote tape drive use the tar and dd commands.
$ tar cf - files | rsh remotehost dd of=/dev/rmt/n obs=blocksize |
tar cf |
Creates a tape archive and specifies the tape device. |
- (Hyphen) |
Represents a placeholder for the tape device. |
files |
Identifies files to be copied. |
| rsh remotehost |
Pipe the tar command's output to a remote shell to copy the files. |
dd of=/dev/rmt/n |
Represents the output device. |
obs=blocksize |
Represents the blocking factor. |
Remove the tape from the drive and write the names of the files on the tape label.
# tar cvf - * | rsh mercury dd of=/dev/rmt/0 obs=126b a answers/ 0 tape blocks a answers/test129 1 tape blocks a sc.directives/ 0 tape blocks a sc.directives/sc.190089 1 tape blocks a tests/ 0 tape blocks a tests/test131 1 tape blocks 6+9 records in 0+1 records out |
Change to a temporary directory.
$ cd /var/tmp |
To extract files to a remote tape drive use the tar and dd commands.
$ rsh remotehost dd if=/dev/rmt/n | tar xvBpf - |
rsh remotehost |
Is a remote shell that is started to extract the files from the tape device using the dd command. |
dd if=/dev/rmt/n |
Indicates the input device. |
| tar xvBpf - |
Pipes the output of the dd command to the tar command used to restored the files. |
Verify that the files have been extracted.
$ ls -l /var/tmp |
$ rsh mercury dd if=/dev/rmt/0 | tar xvBpf - x answers/, 0 bytes, 0 tape blocks x answers/test129, 48 bytes, 1 tape blocks 20+0 records in 20+0 records out x sc.directives/, 0 bytes, 0 tape blocks x sc.directives/sc.190089, 77 bytes, 1 tape blocks x tests/, 0 bytes, 0 tape blocks x tests/test131, 84 bytes, 1 tape blocks $ ls -l /var/tmp |