Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
50.  Copying UFS Files and File Systems (Tasks) Copying Files and File Systems to Tape  Previous   Contents   Next 
   
 

The tape drive and device name you use depend on the hardware configuration for each system. For more information about tape device names, see "Choosing Which Media to Use".

Copying Files to Tape (tar Command)

Here are things you should know before you copy files to tape with the tar command:

  • Copying files to a tape by using the -c option to the tar command destroys any files already on the tape at or beyond the current tape position.

  • You can use file-name substitution wildcards (? and *) as part of the file names you specify when copying files. For example, to copy all documents with a .doc suffix, type *.doc as the file-name argument.

  • You cannot use file-name substitution wildcards when you extract files from a tar archive.

How to Copy Files to a Tape (tar)

  1. Change to the directory that contains the files you want to copy.

  2. Insert a write-enabled tape into the tape drive.

  3. Copy the files to tape.

    $ tar cvf /dev/rmt/n filenames

    c

    Indicates that you want to create an archive.

    v

    Displays the name of each file as it is archived.

    f /dev/rmt/n

    Indicates that the archive should be written to the specified device or file.

    filenames

    Indicates the files and directories you want to copy. Separate multiple files with spaces.

    The file names you specify are copied to the tape, overwriting any existing files on the tape.

  4. Remove the tape from the drive and write the names of the files on the tape label.

  5. Verify that the files you copied are on the tape.

    $ tar tvf /dev/rmt/n

    For more information on listing files on a tar tape, see "How to List the Files on a Tape (tar)".

Example--Copying Files to a Tape (tar)

The following example shows how to copy three files to the tape in tape drive 0.

$ cd /export/home/kryten
$ ls reports
reportA reportB reportC
$ tar cvf /dev/rmt/0 reports
a reports/ 0 tape blocks
a reports/reportA 59 tape blocks
a reports/reportB 61 tape blocks
a reports/reportC 63 tape blocks
$ tar tvf /dev/rmt/n 

How to List the Files on a Tape (tar)

  1. Insert a tape into the tape drive.

  2. Display the tape contents.

    $ tar tvf /dev/rmt/n

    t

    Lists the table of contents for the files on the tape.

    v

    Used with the t option, and provides detailed information about the files on the tape.

    f /dev/rmt/n

    Indicates the tape device.

Example--Listing the Files on a Tape (tar)

The following example shows a listing of files on the tape in drive 0.

$ tar tvf /dev/rmt/0
drwx--x--x   0/1        0 Jul 14 09:24 2001 reports/
-rw------t   0/1    30000 Jul 14 09:23 2001 reports/reportA
-rw------t   0/1    31000 Jul 14 09:24 2001 reports/reportB
-rw------t   0/1    32000 Jul 14 09:24 2001 reports/reportC

How to Retrieve Files From a Tape (tar)

  1. Change to the directory where you want to put the files.

  2. Insert the tape into the tape drive.

  3. Retrieve the files from the tape.

    $ tar xvf /dev/rmt/n [filenames]

    x

    Indicates that the files should be extracted from the specified archive file. All files on the tape in the specified drive are copied to the current directory.

    v

    Displays the name of each file as it is retrieved.

    f /dev/rmt/n

    Indicates the tape device that contains the archive.

    filenames

    Specifies a file to retrieve. Separate multiple files with spaces.

    For more information, see tar(1).

  4. Verify that the files are copied.

    $ ls -l 

Example--Retrieving the Files on a Tape (tar)

The following example shows how to retrieve all the files from the tape in drive 0.

$ cd /var/tmp
$ tar xvf /dev/rmt/0
x reports/, 0 bytes, 0 tape blocks
x reports/reportA, 0 bytes, 0 tape blocks
x reports/reportB, 0 bytes, 0 tape blocks
x reports/reportC, 0 bytes, 0 tape blocks
x reports/reportD, 0 bytes, 0 tape blocks
$ ls -l

Note - The names of the files extracted from the tape must exactly match the names of the files stored on the archive. If you have any doubts about the names or paths of the files, first list the files on the tape. For instructions on listing the files on the tape, see "How to List the Files on a Tape (tar)".


Copying Files to a Tape With the pax Command

How to Copy Files to a Tape (pax)

  1. Change to the directory that contains the files you want to copy.

  2. Insert a write-enabled tape into the tape drive.

  3. Copy the files to tape.

    $ pax -w -f /dev/rmt/0 filenames

    -w

    Enables the write mode.

    -f /dev/rmt/0

    Identifies the tape drive.

    filenames

    Indicates the files and directories you want to copy. Separate multiple files with spaces.

    For more information, see pax(1).

  4. Verify that the files are copied to tape.

    $ pax -f /dev/rmt/0
  5. Remove the tape from the drive and write the names of the files on the tape label.

 
 
 
  Previous   Contents   Next