RestoringDataLogo

The restore command is used to retrieve files from a backup tape or other medium that was created by dump. You can use restore to recover an entire file system or to interactivel select individual files. It recovers files from the specified media and copies them into the current directory (the one you ran the recover command in), re-creating subdirectories as needed. Much as with the dump command, the first parameter passed to the restore command is a list of single-character option codes.

 

 

Restore Options Description

-r Restore the entire dump archive.

 

-C Compare the contents of the dump file with the files on the disk. This is used to check the success of a restore.

 

-R Start the restore from a particular tape of a multitape backup. This is useful for restarting an interrupted restore.

 

-X filelist Extract only specific files or directories from the archive. This option takes one argument, a list of files or directories to extract.

 

-T file List the contents of the dump archive. If a file or directory is given as an argument, list only the occurrence of that file, directory, or anything within the directory.

 

-i Restore files in interactive mode.

 

-b blocksize Specify the block size of the dump in kilobytes. This option takes a numeric argument.

 

-D filesystem Specify the name of the file system to be compared when using the –C option. The file system name is passed as an argument.

 

-F script Specify the name of the dump archive to restore from. This option takes an alphanumeric argument.

 

-h If this option is specified, restore re-creates directories marked for extraction but will not extract their contents.

 

-m Files are extracted by inode number instead of name. This is generally not very useful.

 

-N Instead of extracting files, print their names.

 

-s file# Specify the dump file to start with on a multiple file tape. This takes a numeric argument.

 

-T directory Tells restore where to write any temporary files. This is useful if you booted from a floppy disk (which has no space for temporary files).

 

-v Run in verbose mode. This causes restore to print information about each file as it restores it

 

After creating a file system on your new disk, mount the partition to a temporary mount point.

 

# mkdir /mnt/test

# mount /dev/sdb1 /mnt/test

 

 

This connects the new file system to the /mnt/test directory. Now change into the directory (cd /mnt/test) and use the restore command to recover the entire file system off of your backup tape. Of course, it is assumed that you have loaded the tape into the tape drive.

 

# cd /mnt/test

# restore rf /dev/nrft0

 

When the restore is finished, you can unmount the partition and remount it to the appropriate mount point. If you have restored the file system to a different physical partition than it was originally on, be sure to modify the /etc/fstab file appropriately so that the correct partition is mounted next time the system is rebooted

 

 

Recovering individual files

 

The restore command can also be used to recover individual files and directories. By using restore in interactive mode, you can type a series of restore commands to selectively restore files. To run restore in interactive mode, use the i parameter instead of r:

 

# restore if /dev/nrst0

 

The restore command will then read the file index from the backup tape and present you with a restore prompt. At this prompt, you can type the commands that enable you to select which directories and files to recover. You can navigate the directory structure of the backup index much the same way that you navigate an actual file system using a shell prompt. The interactive restore command even has its own version of the familiar cd and ls commands

 

As an example, pretend that the user joe has accidentally deleted his Mail subdirectory from his home directory. Joe happens to be your boss, so it is urgent that you recover his files. Here is how you can go about it.

Load the appropriate tape into the tape drive and log in as root. Use the cd command to go to the top of the /home partition, and then run the restore program in interactive mode:

 

# cd /home

# restore if /dev/nrft0

 

Verify that you have the backup tape for the /home partition by entering the ls command. You should see something like the following list of directories, representing users who have home directories in /home:

 

restore > ls

.:

bob/ jane/ joe/ lost+found/ mary/ thad/

 

 

Yes, this is the home partition. Now change the current directory to Joe’s home directory using

the cd command. Type ls again to view the contents of his home directory.

 

 

restore > cd joe

restore > ls

./joe:

.mozilla/ Desktop/ report.html

.tcshrc Mail/ letter.txt

.xinitrc News/ www/

 

 

Now mark the Mail directory for extraction using the add command:

 

restore > add Mail

 

If you use the ls command again, you see that the Mail directory is preceded with an asterisk (*) character, which means it has been marked for extraction.

 

restore > ls

./joe:

.mozilla/ Desktop/ report.html

.tcshrc *Mail/ letter.txt

.xinitrc News/ www/

 

Now use the extract command to begin the extraction process. restore will prompt you for the number of the tape to start with. This is a single tape backup, so just enter the number 1. When it prompts you to set owner/mode for ‘.’?, answer yes by typing y and pressing Enter. restore will then restore the file permissions (if necessary) of the directory it is restoring to. This isn’t critical when extracting individual files like this, but you should always answer yes to this prompt when doing a full restore. Anyway, your screen should now contain the following:

 

restore > extract

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 toward the first.

Specify next volume #: 1

set owner/mode for ‘.’? [yn] y

restore >

 

At this point, the files have been recovered and you can exit the restore program by issuing the quit command. That’s all there is to it. You now know the basics of using the dump and restore commands.