The whole idea of backing up files is to have a copy of critical data in case something happens to the server. Ideally, you will never have to restore from backup in your administrative career. Achieving that ideal, though, is unlikely. You need to know how to restore backups after you've created them.
The ufsrestore command is used to restore files backed up with ufsdump. When you restore, you copy files from a backup media back to an active hard disk. Files can be restored from full or incremental dumps, with no major differences in ufsrestore syntax. If the superuser runs ufsrestore, files are restored with their original owner, last modification time, and permissions.
Before you begin a restore, you should have the tapes you need to perform the restore, the raw device name of the device you want to restore to, and a list of files or file systems you want to restore.
One of the features of ufsrestore is that it restores files in relation to their original directory location. For example, files in /export/home/qdocter are saved in relation to the file system, in this case /export/home. Therefore, the file /export/home/qdocter/solbook is written to tape as ./qdocter/solbook, and when restored to the /var/tmp directory, it would be restored to /var/tmp/qdocter/solbook.
This restoration procedure can become quite confusing if you are restoring a large number of files. If you want, you can create subdirectories in /var/tmp to restore to and then move the files to their needed locations after the restorations are complete.
Warning |
Never restore files to the /tmp directory. The /tmp directory uses the TMPFS file system, which does not support UFS security features such as Access Control Lists (ACLs). |
The syntax for ufsrestore is as follows:
# ufsrestore options arguments filename(s)
There are only five options for ufsrestore. They are shown in Table 9.2.
Option |
Description |
---|---|
i |
Interactive; gives you some control over the restoration. |
r |
Recursive; re-creates the entire file system relative to the current working directory. |
R |
Resume; resumes an interrupted r-mode ufsrestore. |
t |
Table of contents; lists each filename that appears on the media. |
x |
Extract; enables you to remove only the requested files from the media. |
Quite a number of arguments are available for ufsrestore. Some of the more common ones are listed in Table 9.3.
As an example, if you wanted to begin a recursive restore from the first tape device, you could use the following command:
# ufsrestore rf /dev/rmt/0
Or, to begin an interactive restore from the same device, you could use:
# ufsrestore if /dev/rmt/0
Interactive restorations enable you to use some shell-like commands to browse and interact with the restore media. The interactive commands supported are listed in Table 9.4.
As you can see by the commands available, interactive mode gives you a considerable amount of control over the restoration process.
Note |
If you do not specify a setmodes option, you will be prompted with set owner /mode for '.' [yn] after the restoration is complete. Understanding the differences between saying "yes" and saying "no" is critical because your answer will greatly affect the security of restored files. |
You can also restore from remote locations, such as remote tape drives or remote hard disks. To restore remotely, you need to specify the location of the media you want to restore from. Here's an example of restoring from the first tape device on a server named fido:
# ufsrestore xf fido:/dev/rmt/0
Interactive and recursive restorations can also be performed when the restoration media is located on a remote system.
So far, this chapter has discussed only restoring files from a tape backup, not necessarily restoring entire file systems. Restoring full file systems is an involved process and can take quite a bit of time if the file system is large. But if the file system is irreparably damaged or corrupted, or the hard disk has failed, you might not have any other choice. Restoring the root (/) and /usr file systems requires its own special process, which will be covered later in this section.
Before you can restore an entire file system, you must have superuser or equivalent rights. These steps also require you to have unmounted the old file system, replaced hardware as necessary, and created a new file system at least large enough to hold the file system you want to restore.
Note |
For information on creating file systems, see Chapter 7, "File System Management." |
After you have created the new file system, you can follow these steps to restore the old file system from backup:
Mount the file system you just created on a temporary mount point. The temporary mount point can be called anything you would like, but for brevity, you can use /new.
# mount /dev/dsk/device_name /new
Change directories to your new mount point.
# cd /new
Insert the tape containing your last full backup into the tape drive and restore the files.
# ufsrestore rvf /dev/rmt/0
If you have incremental dumps more current than your last full dump, continue restoring, from lowest-level dump to highest, until all your dumps are restored.
Check to ensure that the file system is restored properly. How you do this is up to you, but an easy way is to use the ls command to verify that the right files are in the right places.
Remove the restoresymtable file. This file is used by ufsrestore as a check point in the restore process and is no longer needed.
# rm restoresymtable
Change to another directory (such as the root) and unmount the new file system.
# cd / # umount /new
Insert a new, blank tape and make a full backup of the new file system. After all the work you have performed to restore this file system, you had better make a fresh dump.
# ufsdump 0uf /dev/rmt/0 /dev/rdsk/device_name
Mount the new file system.
# mount /dev/dsk/device_name mount_point
Verify access to the newly restored and mounted file system.
# ls mount_point
Your file system should be restored and operational.
The root (/) and /usr file systems are the two most critical file systems to Solaris operation. In fact, they are the only two required file systems to operate Solaris. Because of their critical nature, and because the root file system is used to boot, restoring these two file systems requires special steps.
As with restoring any other file system, you need to have superuser or equivalent rights. You also must have added a new system disk to the computer and created a new file system on it. You will have to boot to the CD-ROM or to the network to restore the file system. After those tasks are completed, follow this procedure:
Mount the file system you just created on a temporary mount point. The temporary mount point can be called anything you would like, but for brevity, you can use /new.
# mount /dev/dsk/device_name /new
Change directories to your new mount point.
# cd /new
Insert the tape containing your last full backup into the tape drive and restore the files.
# ufsrestore rvf /dev/rmt/0
If you have incremental dumps more current than your last full dump, continue restoring, from lowest-level dump to highest, until all your dumps are restored.
Check to ensure that the file system is restored properly. How you do this is up to you, but an easy way is to use the ls command to verify that the right files are in the right places.
Remove the restoresymtable file. This file is used by ufsrestore as a check point in the restore process and is no longer needed.
# rm restoresymtable
Change to another directory (such as the root) and unmount the new file system.
# cd / # umount /new
Check the new file system for consistency.
# fsck /dev/rdsk/device_name
Create boot blocks on the new root partition.
# installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk
/dev/rdsk/device_name
Insert a new, blank tape and make a full backup of the new file system. After all the work you have performed to restore this file system, you had better make a fresh dump.
# ufsdump 0uf /dev/rmt/0 /dev/rdsk/device_name
Repeat steps 1 through 10 for the /usr file system, if necessary.
Reboot the system.
# init 6
Your root (/) and /usr file systems should be restored and operational.
This HTML Help has been published using the chm2web software. |