System Administration Guide, Volume I

Restoring Files and File Systems

Things you need to know:

How to Determine Which Tapes to Use

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

  2. Refer to your backup plan to find the date of the last backup that would have the file or file system on it.

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

  3. If you have online archive files, use the ufsrestore command to identify correct media.


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

    t

    List each file that appears on the tape. 

    a

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

    archive-name

    Identifies the online archive file name. 

    ./path/filename

    Identifies the file name(s) you are looking for on the online archive. If successful, ufsrestore will print out the inode number and file name. If unsuccessful, ufsrestore will print an error message.

  4. Insert the media containing the backups in the drive and use the ufsrestore command to verify the correct media.


    # ufsrestore tf device-name ./path/filename ./path/filename
    

    Be sure to use the complete path for the filename(s). If a file is in the backup, its name and inode number is listed. Otherwise, a message says it is not on the volume.

  5. If you have multiple dump files on the same tape, use the s /dev/rmt/n option to position the tape at the dump you want to use.


    # ufsrestore tfs /dev/rmt/n tape_number
    

Example--Determining Which Tapes to Use

If you use ufsdump to dump the /usr file system, the table of contents lists only the files and directories under /usr. The following example checks if /usr/bin/pwd is in the online archive.


# ufsrestore ta archive-name ./bin/pwd

The following example checks if /usr/bin/pwd is on the backup tape.


# ufsrestore tf /dev/rmt/n ./bin/pwd

How to Restore Files Interactively

  1. Become superuser.

  2. Write-protect the tape.

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

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


    # cd /var/tmp
    

    To avoid conflicts with other users, you may 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 start the interactive restoration.

    Some informational messages and the ufsrestore> prompt are displayed.


    # ufsrestore if /dev/rmt/n
    
  6. Create a list of files to be restored.

    1. List the contents of a directory.


      ufsrestore> ls directory
      
    2. Change to a directory.


      ufsrestore> cd directory-name
      
    3. Create a list of files and directories you want to restore.


      ufsrestore> add filename filename
      
    4. (Optional) If you need to remove a directory or file name from the list of files to be restored, use the delete command.


      ufsrestore> delete filename
      
  7. (Optional) Turn on verbose mode to display the file names as they are being restored.


    ufsrestore> verbose
    
  8. Use the extract command after the list is complete.


    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 keep the mode of the current directory unchanged, enter n at the set owner/mode prompt.


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

    A delay will occur while ufsrestore performs its final cleanup.

  11. Quit the ufsrestore program.


    ufsrestore> quit
    

    The shell prompt is displayed.

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

    3. Move the files to the proper directories.

Example--Restoring Files Interactively

The following example extracts the files /etc/passwd and /etc/shadow from the backup tape.


# cd /var/tmp
# ufsrestore if /dev/rmt/0
ufsrestore> ls
.:
 .cpr_config   etc/          lost+found/   sbin/         usr/
 TT_DB/        export/       mnt/          sccs/         var/
 b/            home/         net/          share/        vol/
 bin           kernel/       opt/          shared/       ws/
 dev/          lib           platform/     src/          xfn/
 devices/      license/      proc/         tmp/
ufsrestore> cd etc
ufsrestore> add passwd shadow
ufsrestore> verbose
verbose mode on
ufsrestore> extract
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/shadow
extract file ./etc/passwd
Add links
Set directory mode, owner, and times.
set owner/mode for `.'? [yn] n
ufsrestore> quit
# 

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 may 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 ...

    x

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

    v

    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: Tue Jun 09 14:30:16 1998
Dumped from: the epoch
Level 0 dump of / on pluto:/dev/dsk/c0t3d0s0
Label: none
Extract directories from tape
Initialize symbol table.
Warning: ./etc: File exists
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
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

How to Restore Files Using a Remote Tape Drive

You can restore files from a remote tape drive by adding remote-host: to the front of the tape device name when using the ufsrestore command.


ufsrestore xf [user@]remote-host:/dev/rmt/n filename 

Example--Restoring Files Using a Remote Drive

The following example restores files using a remote tape drive /dev/rmt/0 on the system venus.


# ufsrestore xf venus:/dev/rmt/0 filename

How to Restore a Complete File System


Note -

You cannot use this procedure to restore root (/) or /usr. See "How to Restore the root (/) and /usr File Systems" for instructions on restoring these file systems.


  1. Become superuser.

  2. If necessary, unmount the file system.


    # umount /dev/rdsk/device-name
    
  3. Create the new file system with the newfs(1M) command.


    # newfs /dev/rdsk/device-name
    

    You are asked if you want to construct a new file system on the raw device. Verify that the device-name is correct so you don't wipe out the wrong file system.

  4. Confirm that the new file system should be created.


    newfs: construct a new file system /dev/rdsk/cwtxdysz:(y/n)? y
    

    The new file system is created.

  5. Mount the new file system on a temporary mount point.


    # mount /dev/dsk/device-name /mnt
    
  6. Change to the /mnt directory.


    # cd /mnt
    

    You have changed to the mount-point directory.

  7. Write-protect the tapes.

  8. Insert the first volume of the level 0 tape into the tape drive.

  9. Use the ufsrestore command to restore the files on the tapes.


    # ufsrestore rvf /dev/rmt/n
    

    The level 0 dump is restored. If the dump required multiple tapes, you will be prompted to load each tape in order.

  10. Remove the tape and load the next level tape in the drive.

    Always restore tapes starting with 0 and continuing until you reach the highest level.

  11. Repeat Step 7 through Step 10 for each level of dump, from the lowest to the highest level.

  12. Verify the file system is restored.


    # ls
    
  13. Remove the restoresymtable file.


    # rm restoresymtable
    

    The restoresymtable file created by ufsrestore is removed.

  14. Change to another directory.


    # cd /
    
  15. Unmount the newly restored file system.


    # umount /mnt
    
  16. Remove the last tape and insert a new tape that is not write-protected in the tape drive.

  17. Use the ufsdump command to make a level 0 backup of the newly restored file system.


    # ufsdump 0uf /dev/rmt/n /dev/rdsk/device-name
    

    You should always do an immediate backup of a newly created file system, because ufsrestore repositions the files and changes the inode allocation (the restored file system will appear to have changed since the previous backup).

  18. Mount the restored file system.


    # mount /dev/dsk/device-name mount-point
    

    The restored file system is mounted and available for use.

  19. Verify the restored and mounted file system is available.


    # ls mount-point
    

Example--Restoring a Complete File System

The following example restores the /export/home file system.


# umount /export/home
# newfs /dev/rdsk/c0t3d0s7
newfs: construct a new file system /dev/rdsk/c0t3d0s7: (y/n)? y
/dev/rdsk/c0t3d0s7:		410400 sectors in 270 cylinders of 19 tracks, 80 sectors
		200.4MB in 17 cyl groups (16 c/g, 11.88MB/g, 5696 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
 32, 24432, 48832, 73232, 97632, 122032, 146432, 170832, 195232, 219632,
 244032, 268432, 292832, 317232, 341632, 366032, 390432,
# mount /dev/dsk/c0t3d0s7 /mnt
# cd /mnt
# ufsrestore rvf /dev/rmt/0
Verify volume and initialize maps
Media block size is 126
Dump   date: Tue Jun 09 15:01:03 1998
Dumped from: the epoch
Level 0 dump of /export/home on pluto:/dev/dsk/c0t3d0s7
Label: none
Begin level 0 restore
Initialize symbol table.
Extract directories from tape
Calculate extraction list.
Warning: ./lost+found: File exists
Make node ./kryten
Make node ./kryten/letters
Make node ./kryten/memos
Make node ./kryten/reports
Make node ./rimmer
Make node ./rimmer/sc.directives
Make node ./rimmer/tests
Make node ./rimmer/answers
Extract new leaves.
Check pointing the restore
# ls
# rm restoresymtable
# cd /
# umount /mnt
# ufsdump 0ucf /dev/rmt/0 /export/home
                    .
 
                    .
 
                    .
# mount /dev/dsk/c0t3d0s7 /export/home
# ls /export/home

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

  1. Add a new system disk to the system where the root (/) and /usr file systems will be restored.

    For a detailed description about adding a system disk, refer to Chapter 23, SPARC: Adding a Disk (Tasks) or Chapter 24, x86: Adding a Disk (Tasks).

  2. Mount the new file system on a temporary mount point.


    # mount /dev/dsk/device-name /mnt
    
  3. Change to the /mnt directory.


    # cd /mnt
    
  4. Write-protect the tapes.

  5. Use the ufsrestore command to restore the root file system.


    # ufsrestore rvf /dev/rmt/n
    

    The level 0 tape is restored.

  6. Remove the tape and load the next level tape in the drive.

    Always restore tapes starting with 0 and continuing from lowest to highest level.

  7. Continue to use the ufsrestore command as needed.


    # ufsrestore rvf /dev/rmt/n
    

    The next level tape is restored.

  8. Repeat Step 6 and Step 7 for each additional tape.

  9. Verify the file system is restored.


    # ls
    
  10. Remove the restoresymtable file.


    # rm restoresymtable
    

    Removes the restoresymtable file that is created and used by ufsrestore to check point the restore.

  11. Change to the root (/) directory.


    # cd /
    
  12. Unmount the newly created file system.


    # umount /mnt
    
  13. Check the new file system.


    # fsck /dev/rdsk/device-name
    

    The restored file system is checked for consistency.

  14. Create the boot blocks on the root partition by using the installboot(1M) command.


    # installboot  /usr/platform/`uname-i`/lib/fs/ufs/bootblk /dev/rdsk/devicename
    

    See "Example--Restoring the root (/) File System on a SPARC System" for an example of using the installboot command on a SPARC system or "Example--Restoring the root (/) File System on an x86 System" for an example of using the installboot command on an x86 system.

  15. Insert a new tape in the tape drive.

  16. Back up the new file system.


    # ufsdump 0uf /dev/rmt/n /dev/rdsk/device-name
    

    A level 0 backup is performed. Always do an immediate backup of a newly created file system because ufsrestore repositions the files and changes the inode allocation.

  17. Repeat steps 5 through 18 for the /usr file system, if necessary.

  18. Reboot the system.


    # init 6
    

    The system is rebooted.

Example--Restoring the root (/) File System on a SPARC System


# mount /dev/dsk/c0t3d0s0 /mnt
# cd /mnt
# tapes
# ufsrestore rvf /dev/rmt/0
# ls
# rm restoresymtable
# cd /
# umount /mnt
# fsck /dev/rdsk/c0t3d0s0
# installboot /usr/platform/sun4m/lib/fs/ufs/bootblk /dev/rdsk/c0t3d0s0
# ufsdump 0uf /dev/rmt/0 /dev/rdsk/c0t3d0s0
# init 6

Example--Restoring the root (/) File System on an x86 System


# mount /dev/dsk/c0t3d0s0 /mnt
# cd /mnt
# tapes
# ufsrestore rvf /dev/rmt/0
# ls
# rm restoresymtable
# cd /
# umount /mnt
# fsck /dev/rdsk/c0t3d0s0
# installboot /usr/platform/`uname -i`/lib/fs/ufs/pboot  /usr/platform/`uname -i`/lib/fs/
ufs/bootblk /dev/rdsk/c0t3d0s0
# ufsdump 0uf /dev/rmt/0 /dev/rdsk/c0t3d0s0
# init 6