RECOVER - Recover Lost Files

  1. What it is
  2. The Recover Command
  3. A Simple Walkthrough

What it is

The recover utility allows users to restore files from backup dump images that were made at some time in the past. Dump images are created approximately nightly. A file has to have existed at the time that the dump image was created in order for it to be recoverable. For example, files created at 6 in the morning and destroyed at 3 in the afternoon are not likely going to be found on an existing dump image.

After a week, previous dump images are thinned out so that not every day is available. Which dump images are still available depends on the filesystem involved. For example, email inboxes and folders are only kept for one week, web page backups are kept for a year.

The Recover Command

The unix recover utility supports a text window as the least common denominator. Screens are presented, prompting you through the steps in finding the files you want to restore. In each of these screens you use the basic arrow keys on your keyboard to highlight your choice and then use an action key (listed at the bottom of the screen) to operate on the selection. If your arrow keys aren't supported, or if you simply don't like to use the arrow keys, you can also use the standard "vi editing" keys, H, J, K, and L to move left, down, up, and right, respectively. At most any screen you can use "Q" to quit and "?" to get a bit of help.

The unix superuser is permitted to restore files on behalf of other users. Normally a user can only restore files that were owned by their UID at the time of the dump. If you need to have a file restored that was owned by a different UID, even if that file was in a directory that you owned and was readable by you at the time of the dump, you need to seek out a system administrator or the original owner to retrieve the file. This is for your protection. You wouldn't want someone to be able to grab your files off a backup image just because you accidently left it world-readable two months ago.

The superuser can restore files with recover in two modes. With, or without, the -u user option on the recover command. Without the option, files are restored with their original ownership. This mode is good for restoring an entire filesystem that has been destroyed. With the -u user option, the retrieved files all end up being owned by the specified user regardless of original ownership. The restore process actually runs with the user's limitations as well, so files can only be restored where that user has permission to write and within that user's allowed disk quota. This is good for restoring files from one account to another.

A Simple Walkthru

The Welcome Screen
Recover starts out by presenting a screen that asks you where the files to be restored were at the time they were lost or destroyed. Some suggested directories are presented; the home directory, the web directory and the deskmail directory for the user being restored and the current directory where recover was invoked. If one of these entries is desired, it can be highlighted and selected with the enter (or return) key. If some other directory is desired, the Other entry can be highlighted and selected with enter and you'll be prompted to fill in a path name for the directory. Rather than arrowing down to the Other entry and selecting it with enter, you can simply type a slash (/) as a shortcut as long as the desired path name starts with a slash.

Once an initial directory is chosen, only files below that directory can be selected during that recover session. Therefore, you should choose a directory that includes everything you want to restore. For example, if a web page in /hw00/d60/krl/projects was to be restored the Current directory in the figure seems like a reasonable choice. However, if that web page references some images that were in /hw00/d60/krl/images that also need to be restored, the parent directory, Web for krl would be a better choice. On the other end of the spectrum, note that /rc51/d99/krl/public_html is a symbolic link pointing to krl's web directory /hw00/d60/krl. Since the web directory is on a separate filesystem (/hw01 versus /rc51), selecting the Home for krl wouldn't get you to the files that you wanted to restore. If you need to restore files that appeared on two or more separate filesystems, you'll need to invoke recover multiple times; once for each filesystem.

The Homer system does not have direct access to the deskmail directories, but recover can restore files from their dump images nonetheless. The deskmail: prefix on the pathname cues this special case restore. However, it cannot put the restored file back into the folder collections for the deskmail system. If you want to put a restored folder back into the folder collections for the deskmail system, you should run the recover utility on the deskmail system directly.

Selecting Dump Image
Once you've selected a directory and recover has determined what filesystem that directory is on, it will present you with a list of dump images available for that filesystem. Highlight the date of the image that has the best chance of having your file intact on in and select it with the enter key. Please be aware that the times indicate when the dumping process started. The dumping process can take several hours. If you want to restore a file that was destroyed at 1 in the afternoon, a dump that started at noon may very well have gotten the to the file after it was destroyed. You may have to go to the previous dump image to retrieve a valid copy of the file.

Choosing Destination Directory
After you've selected a dump image, you'll be asked where the restored file(s) should be placed. You should NOT have the files restored back to their original locations unless you're absolutely sure that nothing will attempt to access the files before they're fully restored. It is almost always better to restore the files into another directory and then rename or copy them into their final location after the restore process completes. Recover will create the directory you specify. If you happen to specify a directory that already exists, recover will prompt you with a Yes or No query asking if you want to overwrite existing files.

Retrieving File List
Once all the pertinent information has been specified, recover will connect to the backup archive server system to retrieve the list of files on that dump image. Up until this point, all the information needed about the dumps has been gotten off of disks. The backup archive server may need to access tapes to get the file list so there may be a delay. The number of other processes that are accessing tape drives and how many tape drives are available will determine how long the delay will be. Fortunately the tapes accessed by the backup archive server are all controlled robotically so you won't have to wait for a human to see the tape request and mount the tape.

Selecting Files
The restore utility presents you with a list of files as they appeared when the dump image was generated. You can select individual files by highlighting them and using the A key to add them to the extraction list, or you can use the * (asterisk) key to select all files at this level and any lower level. Selected files appear on the list with an asterisk to the left of their names. If you wish to select individual files contained within a subdirectory, you can highlight the directory and press the greater-than (>) or enter key to descend into the directory (note that the period, an uncapitalized greater-than, also works to descend into a subdirectory). You can use the less-than (or comma) to return to the parent directory. Subdirectories with some, but not all, files selected to be restored are listed with a plus symbol to the left of their names. You can unselect files or entire directories and their contents by highlighting them and pressing the R key.

Extracting Files
Once you're satisfied with the selection list, use the X key to start the extraction process. Unless there was an earlier restore run on the same dump image, this step must load the dump image in from tape so there will be a delay. How long the delay is depends on how many other dump and restore requests are going on at the same time. As files are restored, the Loaded file and byte counts will increment.

When the extraction process is complete, you'll be given a "Press space to continue" type prompt. After you press the space key, you'll be taken back to the Selecting Files screen. If there are no more files to be restored from that dump image, you should then press Q to quit.


Ken Lowe
Email --
ken@u.washington.edu
Web -- http://staff.washington.edu/krl/