System Administration Guide, Volume 1

How to Restore Specific Files Non-Interactively

  1. Become superuser.

  2. Write-protect the tape for safety.

  3. Insert the volume 1 tape into the tape drive.

  4. Change to a directory for restoring files temporarily.

    # cd /var/tmp

    To avoid conflicts with other users, you might want to create and change to a subdirectory, such as /var/tmp/restore, in which to restore the files.

    If you are restoring a hierarchy, you should restore the files in a temporary directory on the same file system where the files will reside, so you can use the mv command to move the entire hierarchy where it belongs after it is restored.

  5. Use the ufsrestore command to restore the file.

    # ufsrestore xvf /dev/rmt/n filename ...


    Tells ufsrestore to copy specific files or directories in the filename argument.


    Displays the file names as they are restored. 

    f /dev/rmt/n

    Identifies the tape device name. 

    filename ...

    One or more individual file or directory names separated by spaces, for example: ./export/home/user1/mail ./export/home/user2/mail.

  6. Type the volume number where files are located and press Return.

    Specify next volume #: 1

    The file is restored to the current working directory.

  7. To keep the mode of the current directory unchanged, type n and press Return at the set owner/mode prompt.

    set owner/mode for '.'? [yn] n
  8. Verify the restored files.

    1. List the restored files and directories.

      # ls -l

      A list of files and directories is displayed.

    2. Check the list to be sure all the files and directories you specified in the list have been restored.

    3. Move the files to the proper directories.

Example--Restoring Specific Files Non-Interactively

The following example restores the passwd and shadow files to the /var/tmp directory.

# cd /var/tmp
# ufsrestore xvf /dev/rmt/0 ./etc/passwd ./etc/shadow
Verify volume and initialize maps
Media block size is 126
Dump   date: Wed Jul 14 08:42:42 1999
Dumped from: the epoch
Level 0 dump of a partial file system on starbug:/etc
Label: none
Extract directories from tape
Initialize symbol table.
Make node ./etc
Extract requested files
You have not read any volumes yet.
Unless you know which volume your file(s) are on you should start
with the last volume and work towards the first.
Specify next volume #: 1
extract file ./etc/passwd
extract file ./etc/shadow
Add links
Set directory mode, owner, and times.
set owner/mode for `.'? [yn] n
Directories already exist, set modes anyway? [yn] n
# cd etc
# mv passwd /etc
# mv shadow /etc
# ls -l /etc