8.2. Server Restore Procedures

Unarguably, the one thing that is more important than performing regular backups is having them available when it comes time to recover an important file!

Obviously, as discussed in Section 8.1, the procedures for performing a restore will differ depending on your choice of a backup solution. In this section, I will discuss methods for restoring files which have been backed up with ``tar'' and ''KDat''.

8.2.1. Restoring with ``tar'':

The following command will restore all files from the ``full-backup-09-October-1999.tar.gz'' archive, which is an example backup of our Linux system (as created in the example commands shown in Section 8.1.1:

tar -zxvpf /archive/full-backup-09-October-1999.tar.gz

The above command extracts all files contained in the compressed archive, preserving original file ownership and permissions. The ``x'' option stands for extract. (The other options are described in Section 8.1.1.

Caution

Caution: Extracting files from a tar archive can be a dangerous thing to do, and should therefore be done with caution. Perhaps the files were not archived without a file path prepended (a few misguided or uninformed developers distribute tarballs of their software offerings like this), meaning they will all be extracted into the current directory. Perhaps the files were archived with leading ``/'' slashes (by specify the ``--absolute-paths'' option when the archive was created), meaning the files will be restored to their absolute locations (even if you didn't want them to be). Or, perhaps the files were archived without leading ``/'' slashes, meaning the files will be restored under the current directory (even if you didn't want them to be). This of course, depends on how the backup was created. For this reason, I strongly recommend testing your ``tar'' command with a ``t'' (type) option first, and then replace the ``t'' with an ``x'' (extract) when you are absolutely sure the command will do what you expect it to.

If you do not need to restore all files contained in the archive, you can specify one or more files that you wish to restore, as in the following example:

tar -zxvpf /archive/full-backup-09-October-1999.tar.gz \
               etc/profile usr/local/bin/tolower

The above command restores the ``etc/profile'' and ``usr/local/bin/tolower'' files from the example archive.

Tip

If you are trying to restore only one or a few files from your archive, you will not be successful unless you specify the < file name and directory path exactly as stored in the archive. The following example might help out:

tar -ztvpf /archive/full-backup-09-October-1999.tar.gz \
    | grep -i profile

In the above example, all files contained in the archive are listed by file name. The resulting output is then piped to the ``grep'' command (using grep's ``i'' option to ignore mixed case), displaying any files containing ``profile'' in either the directory path or file name. Once you determine the exact file name you wish to restore, you can then specify it for extraction in a regular tar command expression.

As mentioned in Section 8.1, when creating an archive file, tar will strip leading ``/'' (slash) characters from file path names. This means that restore files may not end up in the same locations they were backed up from. Therefore, either change to the ``/'' root directory, or use the ``--directory /'' option.

Note

Note: A far safer solution is to restore the desired files under a different directory (for example, your home directory), and then compare, move, or update the files to their original locations afterward.

8.2.2. Restoring with ``KDat'':

To restore one or more files from a KDat-created backup set, insert the backup tape into the drive, choose "Mount Tape" from the "File" menu option (or left-click on the icon that looks like a tape).

KDat will try to read header information from the tape, and if successful, will then try to find the tape index which matches the identification found in the tape header. This tape index is stored on your hard drive, and is a unique file created for each backup tape formatted by KDat, and is updated each time you perform a backup.

If this corresponding tape index is missing (perhaps you are restoring from a backup set created on another machine, or the index file was deleted or somehow corrupted on your hard drive), KDat will inform you of this fact, and ask you if it is okay to recreate the index by reading the tape. Because you will need to recreate it before you will be able to restore your desired files, it makes perfect sense to left-click "Yes".

Note

(Note: Once a tape is reindexed, its name is changed to "Reindexed Tape". You should rename the tape to its original name.)

Once the tape index has been successfully read, it can then used to select the directories or files you wish to restore from the backup set, in much the same manner you used when creating your backup profiles (see Section 8.1 for detailed instructions on the file selection process).

Once you have selected the appropriate files, you can start the restoration process by choosing "Restore..." from the "File" option on the menu bar (or left-click the tape restore icon). KDat will display a dialog box, allowing you to confirm which files will be restored. In addition, you have the option of specifying a directory into which files will be restored. This will allow you to restore critical system files into your home directory, and then compare, move, or update those files to their intended location later on. This is actually the safest way of restoring files.

To begin the recovery process, click the "Okay" button. KDat will then scan the tape and restore the selected files.

On occasion, you may find it necessary or useful to restore one or more files from a backup set created with KDat without using KDat to do so. Perhaps you would like to restore such files on a system that does not offer a GUI-based environment, or would like to do so over a slow network connection through which remote execution of KDat would be impractical. Fortunately, KDat writes its backup data sets using the ``tar'' tool, a command-line based tool that is available on any *nix system.

Should you wish to restore your KDat-created backup set using tar, simply do so using whatever options you would with any normal backup set created with tar itself. Bear in mind, however, that data sets are not stored in compressed format.

Note

Note: You will almost certainly get an error message when trying to access the KDat backup set with tar. This is because of the header and other information that KDat added to the tape when it was first formatted. Simply repeat the tar command two or three times to skip to the beginning of the actual tar archive file.