Example--Retrieving Specific Files From a Tape (cpio)
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 |
Copying Files to a Remote Tape Device
How to Copy Files to a Remote Tape Device (tar and dd)
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.
For more information, see hosts.equiv(4).
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 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.
Change to the directory where you want to put the files.
Insert the tape into the tape drive.
Copy the files to a remote tape drive.
$ tar cvf - filenames | rsh remote-host dd of=/dev/rmt/n obs=block-size
tar cf
Creates a tape archive, lists the files as they are archived, and specifies the tape device.
- (Hyphen)
Represents a place holder for the tape device.
filenames
Identifies the files to be copied.
| rsh remote-host
Pipes the tar command's output to a remote shell.
dd of=/dev/rmt/n
Represents the output device.
obs=block-size
Represents the blocking factor.
Remove the tape from the drive and write the names of the files on the tape label.
Example--Copying Files to a Remote Tape Drive (tar and dd)
# 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 |
How to Extract Files From a Remote Tape Device
Insert the tape into the tape drive.
Change to a temporary directory.
$ cd /var/tmp
Extract the files from a remote tape device.
$ rsh remote-host dd if=/dev/rmt/n | tar xvBpf -
rsh remote-host
Indicates a remote shell that is started to extract the files from the tape device by 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 that is used to restored the files.
Verify that the files have been extracted.
$ ls -l /var/tmp
Example--Extracting Files From a Remote Tape Drive
$ cd /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 |
Copying Files and File Systems to Diskette
Before you can copy files or file systems to diskette, you must format the diskette. For information on how to format a diskette, see Chapter 19, Formatting Removable Media (Tasks).
Use the tar command to copy UFS files to a single formatted diskette.
Use the cpio command if you need to copy UFS files to multiple formatted diskettes. The cpio command recognizes end-of-media and prompts you to insert the next volume.
Note - The use of the cpio command to copy UFS files to multiple formatted diskettes is not a straightforward procedure because of volume management.
Things You Should Know When Copying Files to Diskettes
Copying files to a formatted diskette by using the tar -c command destroys any files that are already on the diskette.
A diskette that contains a tar image is not mountable.
If you need a multiple-volume interchange utility, use the cpio command. The tar command is only a single-volume utility.
For more information, see tar(1).
How to Copy Files to a Single Formatted Diskette (tar)
Change to the directory that contains the files you want to copy.
Insert a formatted diskette that is not write-protected into the drive.
Make the diskette available.
$ volcheck
Reformat the diskette if necessary.
$ rmformat -U /dev/rdiskette Formatting will erase all the data on disk. Do you want to continue? (y/n)y
Copy the files to diskette.
$ tar cvf /vol/dev/aliases/floppy0 filename ...
The file names you specify are copied to the diskette, overwriting any existing files on the diskette.
Verify that the files are copied.
$ tar tvf /vol/dev/aliases/floppy0
For more information on listing files, see "How to List the Files on a Diskette (tar)".
Remove the diskette from the drive.
Write the names of the files on the diskette label.