Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

System Administration Guide: Devices and File Systems
Previous Next

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.


How 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. 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 are listed. Otherwise, a message states that the file is not on the volume.

  5. If you have multiple backup files on the same tape, position the tape at the backup file you want to use.
    # ufsrestore xfs /dev/rmt/n tape-number
Example 27-1 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

How 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.
Example 27-2 Restoring Files Interactively

The following example shows how to extract the /etc/passwd and /etc/shadow files from the backup tape.

# cd /var/tmp
# ufsrestore if /dev/rmt/0
ufsrestore> ls
.:
 .:
 .sunw/        export/       net/          sbin/         usr/
 Sources/      etools/       opt/          scde/         var/
 b/            home/         ptools/       set/          vol/
 bin           kernel/       pkg/          share/        
 dev/          lib/          platform/     shared/
 devices/      lost+found/   proc/         src/
 etc/          mnt/          rtools/       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
# cd etc
# mv passwd /etc
# mv shadow /etc
# ls -l /etc

How to Restore Specific Files Noninteractively

  1. Become superuser or assume an equivalent role.
  2. (Optional) Write-protect the tape for safety.
  3. Insert the volume 1 tape into the tape drive.
  4. Change to a directory that will be used to restore files to temporarily.
    # cd /var/tmp
  5. Restore the file or files.
    # 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

    Specifies one or more file names 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. Press Return.
    Specify next volume #: 1

    The file or files are restored to the current working directory.

  7. To maintain the mode of the current directory, 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 that all the files and directories you specified in the list have been restored.
  9. Move the files to the proper directories.
Example 27-3 Restoring Specific Files Noninteractively

The following example shows how to noninteractively restore 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 28 16:13:52 2004
Dumped from: the epoch
Level 0 dump of / on starbug:/dev/dsk/c0t0d0s0
Label: none
Extract directories from tape
Initialize symbol table.
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.
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
# cd etc
# mv passwd /etc
# mv shadow /etc
# ls -l /etc
Example 27-4 Restoring Files From a Remote Tape Device

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.

The following example shows how to restore files by using a remote tape drive /dev/rmt/0 on the system venus.

# ufsrestore xf venus:/dev/rmt/0 ./etc/hosts

How to Restore a Complete File System

Occasionally, a file system becomes so damaged that you must completely restore it. Typically, you need to restore a complete file system after a disk failure. You might need to replace the hardware before you can restore the software. For information on how to replace a disk, see SPARC: Adding a System Disk or a Secondary Disk (Task Map) or x86: Adding a System Disk or a Secondary Disk (Task Map).

Full restoration of a file system such as /export/home can take a lot of time. If you have consistently backed up file systems, you can restore them to their state from the time of the last incremental backup.


Note - You cannot use this procedure to restore the root (/) or /usr file systems. For instructions on restoring these file systems, see How to Restore the root (/) and /usr File Systems.


  1. Become superuser or assume an equivalent role.
  2. If necessary, unmount the file system.
    # umount /dev/rdsk/device-name

    Or:

    # umount /file-system
  3. Create the new file system.
    # 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 that you don't destroy the wrong file system.

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

  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 mount point directory.
    # cd /mnt
  7. (Optional) Write-protect the tapes for safety.
  8. Insert the first volume of the level 0 tape into the tape drive.
  9. Restore the files.
    # ufsrestore rvf /dev/rmt/n

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

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

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

  11. Repeat Step 8 through Step 10 for each dump level, from the lowest to the highest level.
  12. Verify that the file system has been restored.
    # ls
  13. Remove the restoresymtable file.
    # rm restoresymtable

    The restoresymtable file that is created and used by the ufsrestore command to check-point the restore 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. Make a level 0 backup of the newly restored file system.
    # ufsdump 0ucf /dev/rmt/n /dev/rdsk/device-name

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

  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 that the restored and mounted file system is available.
    # ls mount-point
Example 27-5 Restoring a Complete File System

The following example shows how to restore the /export/home file system.

# newfs /dev/rdsk/c0t0d0s7
newfs: /dev/rdsk/c0t0d0s7 last mounted as /export/home
newfs: construct a new file system /dev/rdsk/c0t0d0s7: (y/n)? y
819314 sectors in 867 cylinders of 15 tracks, 63 sectors
        400.1MB in 55 cyl groups (16 c/g, 7.38MB/g, 3584 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
 32, 15216, 30400, 45584, 60768, 75952, 91136, 106320, 121504, 136688,
 681264, 696448, 711632, 725792, 740976, 756160, 771344, 786528, 801712,
 816896,
# mount /dev/dsk/c0t0d0s7 /mnt
# cd /mnt
# ufsrestore rvf /dev/rmt/0
Verify volume and initialize maps
Media block size is 126
Dump   date: Thu Jul 29 10:14:00 2004
Dumped from: the epoch
Level 0 dump of /export/home on starbug:/dev/dsk/c0t0d0s7
Label: none
Begin level 0 restore
Initialize symbol table.
Extract directories from tape
Calculate extraction list.
Warning: ./lost+found: File exists
Make node ./rimmer
Make node ./rimmer/wdir
Make node ./lister
Make node ./pmorph
Make node ./inquisitor
Make node ./kryten
Make node ./kryten/letters
Make node ./kryten/reports
Extract new leaves.
Check pointing the restore
extract file ./rimmer/words
extract file ./rimmer/words1
extract file ./rimmer/words2
extract file ./rimmer/words3
extract file ./rimmer/wdir/words
extract file ./rimmer/wdir/words1
extract file ./rimmer/wdir/words2
extract file ./rimmer/wdir/words3
.
.
.
Add links
Set directory mode, owner, and times.
Check the symbol table.
Check pointing the restore
# rm restoresymtable
# cd /
# umount /mnt
# ufsdump 0ucf /dev/rmt/0 /export/home
                    .
                    .
                    .
# mount /dev/dsk/c0t0d0s7 /export/home
# ls /export/home

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

  1. Become superuser or assume an equivalent role.
  2. 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 SPARC: How to Connect a System Disk and Boot or x86: How to Connect a System Disk.

  3. Mount the new file system on a temporary mount point.
    # mount /dev/dsk/device-name /mnt
  4. Change to the /mnt directory.
    # cd /mnt
  5. (Optional) Write-protect the tapes for safety.
  6. Create the links for the tape device.
    # tapes
  7. Restore the root (/) file system.
    # ufsrestore rvf /dev/rmt/n

    The dump level 0 tape is restored.

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

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

  9. Continue restoring as needed.
    # ufsrestore rvf /dev/rmt/n

    The next level tape is restored.

  10. Repeat Step 8 and Step 9 for each additional tape.
  11. Verify that the file system has been restored.
    # ls
  12. Remove the restoresymtable file.
    # rm restoresymtable

    The restoresymtable file that is created and used by the ufsrestore command to check-point the restore is removed.

  13. Change to the root (/) directory.
    # cd /
  14. Unmount the newly created file system.
    # umount /mnt
  15. Check the new file system.
    # fsck /dev/rdsk/device-name

    The restored file system is checked for consistency.

  16. Create the boot blocks on the root partition.

    On a SPARC system:

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

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

    For an example of using the installboot command on a SPARC based system, see Example 27-6.

    On an x86 system:

    # /sbin/installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/cwtxdysz

    For more information, see installgrub(1M).

    For an example of using the installgrub command on an x86 based system, see Example 27-7.

  17. Insert a new tape in the tape drive.
  18. Back up the new file system.
    # ufsdump 0uf /dev/rmt/n /dev/rdsk/device-name

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

  19. Repeat steps 5 through 16 for the /usr file system, if necessary.
  20. Reboot the system.
    # init 6

    The system is rebooted.

Example 27-6 SPARC: Restoring the root (/) File System

This example shows how to restore the root (/) file system on a SPARC system. This example assumes that the system is booted from a local CD or from the network.

# 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/sun4u/lib/fs/ufs/bootblk
/dev/rdsk/c0t3d0s0
# ufsdump 0uf /dev/rmt/0 /dev/rdsk/c0t3d0s0
# init 6
Example 27-7 x86: Restoring the root (/) File System

This example shows how to restore the root (/) file system on an x86 system. This example assumes that the system is booted from a GRUB failsafe boot session, local CD, or from the network.

# mount /dev/dsk/c0t3d0s0 /mnt
# cd /mnt
# tapes
# ufsrestore rvf /dev/rmt/0
# ls
# rm restoresymtable
# cd /
# umount /mnt
# fsck /dev/rdsk/c0t3d0s0
# /sbin/installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c0t3d0s0
stage1 written to partition 0 sector 0 (abs 2016)
stage2 written to to partition 0, 227 sectors starting 50 (abs 2066)
# ufsdump 0uf /dev/rmt/0 /dev/rdsk/c0t3d0s0
# init 6
Previous Next

 
 
  Published under the terms fo the Public Documentation License Version 1.01. Design by Interspire