Notice! This document is currently in Archived status.
The content of this document may be incorrect or outdated.

Print this article Edit this article

How to restore a filesystem from a backup tape

Purdue Engineering Computer Network

Backups of filesystems are essential. No matter how carefully the hardware is maintained, or how knowledgeable the users are, eventually every computer facility will be confronted with lost files. Lost files can range from a user deleting a single file to an entire filesystem being deleted due to a hardware failure. Without backups, all data that has changed since the operating system was brought up can (and probably will) be lost to a system failure.

The more often backups are performed, the safer data is from loss. The Engineering Computer Network performs daily incremental backups of filesystems.

Backup Media

In order for backups to be effective, they must be stored on some sort of removable media. System failures can damage many pieces of hardware at the same time, therefore backing up one disk to another would provide very little protection against a controller failure, which might cause the contents of both the disks to be destroyed. Backups to removable media also protect the backup tapes from a physical catastrophe, such as a machine room fire. The Engineering Computer Network uses 8mm videotapes (Exabytes) as the recording media. An 8mm Exabyte tape records quickly and holds about 2.3 gigabytes of data or 5 gigabytes of data.

Ufsrestore

Ufsrestore restores files from backup tapes which were created with the ufsdump command. Ufsrestore takes at least one option, along with modifiers and arguments. Remaining arguments to ufsrestore are the names of the files (or directories whose files) which are to be restored. Unless the h modifier is in effect, a directory name refers to the files it contains, and (recursively) its subdirectories and the files they contain.

Options to Restore

i
Interactive. After reading in the directory information from the media, ufsrestore invokes an interactive interface that allows you to browse through the dump file's directory hierarchy and select individual files to be extracted.

b factor
Blocking factor. Specify the blocking factor for tape reads. In ECN, we use 50.

f
Specifies the tape or diskette drive. Different tape drives will have different names. To find the name of your tape or diskette drive, look at /etc/backup.control. Go to the host where your tape drive is located. Look for the following lines in /etc/backup.control:
rewtape = /dev/rmt/1l
norewtape = /dev/rmt/1ln
You want to use the "norewtape" name.

v
Verbose. Ufsrestore displays the name and inode number of each file it restores, preceded by its file type.

fsf n
Fast forward to the n' th file when there are multiple dump files on the same tape. If using exabyte tape as the media, the command mt -f fsf n would fast forward you to the specified file number. Ufsdump counts the number of filesystems starting from the number 0.For example:
	# mt -f /dev/rmt/1ln fsf n
The command mt stands for "magnetic tape the -f option specifies file, /dev/rmt/1ln is the file for the option -f, fsf is for the "fast forward" command, and n is the number of files to skip.

The interactive commands which are invoked with the i option are as follows:

ls [ directory ]
List files in directory or the current directory (within the dump-tape)

cd directory
Change to directory directory (within the dump-tape)

pwd
Print the full pathname of the current working directory (within the dump-tape)

add
Add the current directory or named file to the extraction list. If a directory is specified, add the directory and its files will recursively be extracted.

delete [ filename ]
Delete the current directory, or the named file or directory from the list of files to extract.

extract
Extract all files on the extraction list from the dump tape.

quit
Restore exits immediately.

Procedure for the Restoration of Individual Files

  • Find the correct backup tape which the requested filesystem is located. On the host which the file was located, look in /etc/backup.tapes. This file contains the name of the filesystem, level of dump, date of dump, reel number and file number. On the appropriate filesystem, find the level of dump you want to restore, and get it's reel and file number.

    The file looks like this:

    ---- Sun May 28 12:03:33 1995 ------------------------------------------------
    /dev/rdsk/c0t3d0s0 level 3 dump begins on reel 1, file 2.
    /dev/rdsk/c0t3d0s6 level 3 dump begins on reel 1, file 3.
    /dev/rdsk/c1t0d0s3 level 3 dump begins on reel 1, file 4.
    /dev/rdsk/c0t3d0s5 level 3 dump begins on reel 1, file 5.
    /dev/rdsk/c0t3d0s3 level 3 dump begins on reel 1, file 6.
    /dev/rdsk/c0t3d0s4 level 3 dump begins on reel 1, file 7.
    /dev/rdsk/c0t3d0s7 level 3 dump begins on reel 1, file 8.
    /dev/rdsk/c1t1d0s2 level 3 dump begins on reel 1, file 9.
    /dev/rdsk/c1t2d0s2 level 3 dump begins on reel 1, file 10.
    /dev/rdsk/c1t0d0s0 level 3 dump begins on reel 1, file 11.
    ---- Sun Jun 4 00:16:50 1995 ------------------------------------------------
    /dev/rdsk/c0t3d0s0 level 0 dump begins on reel 1, file 2.
    /dev/rdsk/c0t3d0s6 level 0 dump begins on reel 1, file 3.
    /dev/rdsk/c1t0d0s3 level 0 dump begins on reel 1, file 4.
    /dev/rdsk/c0t3d0s5 level 0 dump begins on reel 1, file 5.
    /dev/rdsk/c0t3d0s3 level 0 dump begins on reel 1, file 6.
    /dev/rdsk/c0t3d0s4 level 0 dump begins on reel 1, file 7.
    /dev/rdsk/c0t3d0s7 level 0 dump begins on reel 1, file 8.
    continues onto reel 2
    /dev/rdsk/c1t1d0s2 level 0 dump begins on reel 2, file 3.
    /dev/rdsk/c1t2d0s2 level 0 dump begins on reel 3, file 2.
    continues onto reel 4
    /dev/rdsk/c1t0d0s0 level 0 dump begins on reel 5, file 2.
    Suppose the file you need to restore was located on /home/harbor/a/... that is not listed here. But it is. The filesystems are listed as their device names. So which one is /home/harbor/a? On the host "harbor" do a df command. The output will look something like this:
    /                  (/dev/dsk/c0t3d0s0):   56478 blocks   31517 files
    /usr (/dev/dsk/c0t3d0s6): 37654 blocks 41136 files
    /proc (/proc ): 0 blocks 861 files
    /dev/fd (fd ): 0 blocks 0 files
    /var (/dev/dsk/c1t0d0s3): 752914 blocks 245793 files
    /tmp (swap ): 381768 blocks 12632 files
    /opt (/dev/dsk/c0t3d0s5): 26780 blocks 48373 files
    /usr/src (/dev/dsk/c1t2d0s2): 471248 blocks 795460 files
    /usr/local (/dev/dsk/c0t3d0s3): 74746 blocks 88433 files
    /usr/openwin (/dev/dsk/c0t3d0s4): 25622 blocks 52039 files
    /export/home/a (/dev/dsk/c0t3d0s7): 579358 blocks 492667 files
    /export/home/b (/dev/dsk/c1t1d0s2): 615944 blocks 453129 files
    /export/home/data (/dev/dsk/c1t3d0s2): 886264 blocks 492516 files
    /export/home/system(/dev/dsk/c1t0d0s0): 206230 blocks 228671 files
    So /export/home/a is /dev/dsk/c0t3d0s7. So now looking at /etc/backup.tapes, you can see when /dev/dsk/c0t3d0s7 dumped and see it's reel number and file number.

  • Before you get started on the restore, you may want to make a temporary place to work to guard against overwriting an existing file or directory:
    	# mkdir RESTORE
    # cd RESTORE
  • Get the appropriate reel (tape) and insert it on a host which has an exabyte tape drive. Note: each tape has a label on the front which identifies it. You now rlogin to this host. You will then fast forward (fsf) the tape to the appropriate file. The file number listed in the file of backup.tape is not the file number you want to fast forward to. Dump counts the number of filesystems starting from the number 0 (zero). So if you want file number 9, you really want to skip 8 files:
    	# mt -f /dev/rmt/1ln fsf 8
    When your prompt returns, you have arrived.

  • Now you want to execute the ufsrestore command with specified options. The options to use are interactive, verbose, blocking factor, file (in this case the device is the filename). The blocking factor for the restore should be the same blocking factor which was used for the dump. Currently ECN uses the blocking factor of 50 for the dumps. Upon completion of the restore, you will be at the ufsrestore prompt. As stated, the i option lets you browse through the dump tape directory hierarchy to find the requested files to be rested. You can cd and ls through the directories listed.
    	# mt -f /dev/rmt/1ln fsf 8
    #
    # /usr/sbin/ufsrestore -ivbf 50 /dev/rmt/1ln
    The b and f options must be followed in the same order as it's variables. In other words, if you issue -ivbf, you must specify the block number before the device drive. If you issue -ivfb, you must specify the device drive before the block number.

  • Now you will want to add the files you want restored. At the ufsrestore prompt, execute the add command and list the filenames which you want to add (restore). If multiple filenames, they should be separated by a space. Add will automatically execute in a recursive mode:
    		ufsrestore> 
    ufsrestore> add report.doc goals .cshrc
  • The restore will make nodes for the added files. After this is complete, you can do another ls and you will see an asterisk (*) next to the files you have added.

  • Now you want to tell restore to get the files off the tape. You will use the extract command for this accomplishment. At the ufsrestore prompt, execute extract. Since the i option was specified, ufsrestore will ask you a question about the volume. For this time, the answer should always be "1". It might be other numbers if we ever get dumps large enough to require more than one tape to hold them, but this probably will not happen in the near future.
    		ufsrestore> extract
    Extract requested files
    You have not read any tapes yet
    Unless you know which volume your file(s) are on you should start with the last volume and work towards the first.
    Specifying next volume #: 1
  • After the extraction, ufsrestore will ask if you want to
    		set owner/mode for '.'? [yn].
    The answer to this question should *always* be "n" (if you make a mistake andtype "y" it is not serious). There is one special case in which "y" is correct,but only if you're restoring an entire disk (for instance after a disk crash).

  • Get out of ufsrestore:
    		ufsrestore> quit
  • Eject the exabyte tape:
    		# mt -f /dev/rmt/1ln rewoffl
  • Now check what you have restored.
    		# ls -asl
    This should give you the list of files you requested to restore.

  • Now use either mv or rcp to copy the files over to the user's directory, then use the chown program to set the file's ownership to the user.

To see a sample restore session, click here.

Last Modified: Dec 19, 2016 11:12 am US/Eastern
Created: Mar 23, 2007 12:26 pm GMT-4 by admin
JumpURL: