Sun Microsystems Logo
Products & Services
 
Support & Training
 
 

Previous Previous     Contents     Index     Next Next
Chapter 49

Restoring Files and File Systems (Tasks)

This chapter describes how to use the ufsrestore command to restore files and file systems that were backed up by using the ufsdump command.

For information on the procedures associated with restoring files and file systems, see Restoring Files and File System Backups (Task Map).

For information about other commands you can use to archive, restore, copy, or move files and file systems, see Chapter 51, Copying UFS Files and File Systems (Tasks).

For information about backing up and restoring file systems, see Chapter 46, Backing Up and Restoring File Systems (Overview).

Restoring Files and File System Backups (Task Map)

The following task map describes the procedures associated with restoring files and file systems.

Task

Description

For Instructions

Prepare to restore files and file systems

Identify the file systems or files to be restored, the tape device, and how you will restore them.

Preparing to Restore Files and File Systems 

Determine which tapes to use

Refer to your backup tapes to find the date of the last backup that contains the file or file system that you need to restore.

How to Determine Which Tapes to Use 

Restore files

Choose one of the following restore methods:

 

 

Restore files interactively-Use this method when you are unsure of the file names because you can browse the media contents and select individual files and directories.

How to Restore Files Interactively 

 

Restore files noninteractively-Use this method when you already know the few file names to be restored.

How to Restore Specific Files Noninteractively 

 

Restore a file system - Use this method when you get a new disk drive or as part of a recovery procedure.

How to Restore a Complete File System 

Restore the root (/) or /usr file systems

Restoring the root (/) or /usr file systems involves booting the system from a local CD or the network.

How to Restore the root (/) and /usr File Systems 

Preparing to Restore Files and File Systems

The ufsrestore command copies files to disk, relative to the current working directory, from backups that were created by using the ufsdump command. You can use the ufsrestore command to reload an entire file system hierarchy from a level 0 dump and incremental dumps that follow it. You can also use this command to restore one or more single files from any backup tape. If you run the ufsrestore command as superuser, files are restored with their original owner, last modification time, and mode (permissions).

Before you start to restore files or file systems, you need to know the following:

  • The tapes (or diskettes) you need to restore from

  • The raw device name on which you want to restore the file system

  • The type of tape device you will use

  • The device name (local or remote) for the tape device

Determining the File System Name

If you have properly labeled your backup tapes, you should be able to use the file system name (/dev/rdsk/device-name) from the tape label. For more information, see How to Find File System Names.

Determining the Type of Tape Device You Need

You must use a tape device that is compatible with the backup media to restore the files. The format of the backup media determines which drive you must use to restore files. For example, if your backup media is 8-mm tape, you must use an 8-mm tape device to restore the files.

Determining the Tape Device Name

You might have specified the tape device name (/dev/rmt/n) as part of the backup tape label information. If you are using the same drive to restore a backup tape, you can use the device name from the label. For more information on media devices and device names, see Chapter 52, Managing Tape Drives (Tasks).

Restoring Files and File Systems

When you back up files and directories, you save them relative to the file system in which they belong. When you restore files and directories, the ufsrestore command re-creates the file hierarchy in the current working directory.

For example, files backed up from the /export/doc/books directory (where /export is the file system), are saved relative to /export. In other words, the book1 file in the books directory is saved as ./doc/books/book1 on the tape. Later on, if you restored the ./doc/books/book1 file to the /var/tmp directory, the file would be restored to /var/tmp/doc/books/book1.

When you restore individual files and directories, you should restore them to a temporary location, such as the /var/tmp directory. After you verify the files, you can move them to their proper locations. However, you can restore individual files and directories to their original locations. If you do so, be sure you are not overwriting newer files with older versions from the backup tape.

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

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


Note - Do not restore files in the /tmp directory even temporarily. The /tmp directory is usually mounted as a TMPFS file system. TMPFS does not support UFS file system attributes such as ACLs.


ProcedureHow to Determine Which Tapes to Use

  1. Ask the user for the approximate date the files to be restored were last modified.

  2. Refer to your backup plan to find the date of the last backup that contains the file or file system.

    To retrieve the most recent version of a file, work backward through the incremental backups from highest to lowest dump level and from most recent to least recent date, unless the user requests otherwise.

  3. (Optional) If you have online archive files, identify the correct media.

    # ufsrestore ta archive-name ./path/filename ./path/filename

    t

    Lists each file on the tape.

    a

    Reads the table of contents from the online archive file instead of from the tape.

    archive-name

    Identifies the online archive file name.

    ./path/filename

    Identifies the file name or file names you are looking for on the online archive. If successful, the ufsrestore command prints out the inode number and file name. If unsuccessful, ufsrestore prints an error message.

    For more information, see the ufsrestore(1M) man page.

  4. Insert the media that contains the files to be restored in the drive and verify the correct media.

    # ufsrestore tf /dev/rmt/n ./path/filename ./path/filename

    Be sure to use the complete path for each filename. If a file is in the backup, its name and inode number is listed. Otherwise, a message states that the file is not on the volume.

  5. (Optional) If you have multiple backup files on the same tape, position the tape at the backup file you want to use.

    # ufsrestore tfs /dev/rmt/n tape-number 

Examples--Determining Which Tapes to Use

The following example shows how to check if the /etc/passwd file is in the online archive.

# ufsrestore ta /var/tmp/root.archive ./etc/passwd

The following example shows how to verify that the /etc/passwd file is on the backup tape.

# ufsrestore tf /dev/rmt/0 ./etc/passwd

ProcedureHow to Restore Files Interactively

  1. Become superuser or assume an equivalent role.

  2. (Optional) Write-protect the tapes for safety.

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

  4. Change to a directory that will be used to restore the files to temporarily.

    # cd /var/tmp

  5. Start the interactive restoration.

    # ufsrestore if /dev/rmt/n

    Some informational messages and the ufsrestore> prompt are displayed.

  6. Create a list of files to be restored.

    1. List the contents of a directory.

      ufsrestore> ls [directory-name]

    2. Change to a directory.

      ufsrestore> cd directory-name

    3. Create a list of files and directories that you want to restore.

      ufsrestore> add filenames

    4. (Optional) Remove any directory or file from the list of files to be restored, if necessary.

      ufsrestore> delete filename

  7. (Optional) Display the file names as they are being restored.

    ufsrestore> verbose

  8. Restore the files.

    ufsrestore> extract

    The ufsrestore command asks you which volume number to use.

  9. Type the volume number and press Return. If you have only one volume, type 1 and press Return.

    Specify next volume #: 1

    The files and directories in the list are extracted and restored to the current working directory.

  10. To maintain the mode of the current directory, enter n at the set owner/mode prompt.

    set owner/mode for `.'? [yn] n

    You must wait while the ufsrestore command performs its final cleanup.

  11. Quit the ufsrestore program.

    ufsrestore> quit

    You then see the shell prompt.

  12. 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 that all the files and directories you specified in the list have been restored.

  13. Move the files to the proper directories.

Previous Previous     Contents     Index     Next Next
 

Updated: 2004-01-29, 13:14