Содержащиеся в
Найти другие документы
Ресурсы поддержки
| Загрузить это руководство в формате PDF
Restoring Files and File Systems
43
- This chapter describes the procedures for restoring file systems.
- This is a list of step-by-step instructions in this chapter.
-
- This chapter describes how to use the ufsrestore(1M) command to restore files and file systems that were backed up using the ufsdump command. See Chapter 45, "Copying UFS Files and File Systems," for information about other commands you can use to archive, restore, copy, or move files and file systems.
Preparing to Restore Files and File Systems
- The ufsrestore command copies files from backups created using the ufsdump command into the current working directory. You can use ufsrestore to reload an entire file system hierarchy from a level 0 dump and incremental dumps that follow it or to restore one or more single files from any dump tape. If ufsrestore is run by root, files are restored with their original owner, last modification time, and mode (permissions).
- Before you start to restore files or file systems, you need to know:
-
- Which tapes (or diskettes) you need
- The raw device name for the file systems you want to back up
- The type of tape drive you will use
- The device name (local or remote) for the tape drive
Determining the Disk Device Name
- If you have properly labeled your backup tapes, you should be able to use the disk device name (/dev/rdsk/devicename) from the tape label. See "How to Find File System Names" on page 735 for more information.
Determining the Type of Tape Drive You Will Use
- You must use a tape drive that is compatible with the backup media to restore the files. The format of the backup media determines which drive you must use to restore files. For example, if your backup media is 8-mm tape, you must use an 8-mm tape drive to restore the files.
Determining the Tape Device Name
- You may have specified the tape device name (/dev/rmt/n) as part of the backup tape label information. If you are using the same drive to restore a backup tape, you can use the device name from the label. See Chapter 46, "Managing Tape Drives" for more information on media devices and device names.
Restoring Complete File Systems
- Occasionally, a file system becomes so damaged that you must completely restore it. Typically, you need to restore a complete file system because of a disk head crash. You may need to replace the hardware before you can restore the software. See Chapter 29, "SPARC: Adding a Disk," or Chapter 30, "x86: Adding a Disk" for information on how to replace a disk. Fully restoring a file system such as /export/home can take a lot of time. If you have faithfully backed up file systems, you can restore them to their state as of the last incremental backup.
Restoring Individual Files and Directories
- This section describes how to restore individual files and directories using a local tape drive. See "How to Use a Remote Drive to Restore Files" on page 766 for information on how to use a remote drive to restore files.
- When you restore files in a directory other than the root directory of the file system, ufsrestore re-creates the file hierarchy in the current directory. For example, if you restore files to /home1 that were backed up from /home/doc/books the files are restored in the directory /home1/doc/books.
- When restoring individual files and directories, it is a good idea to restore them to a temporary directory such as /var/tmp. After you verify them, you can move the files to their proper locations. You can restore individual files and directories to their original locations. If you do so, be sure you are not overwriting newer files with older versions from the backup tape.
Using a Remote Drive to Restore Files
- You can restore files from a remote drive by adding remote-host: to the front of the tape device name. Here is the syntax:
-
ufsrestore rf [user@]remote-host:/dev/rmt/unit filename
|
- For example, to access /dev/rmt/0 on the system venus, type:
-
# ufsrestore rf venus:/dev/rmt/0 filename
|
Troubleshooting
Make Sure the Backup and Restore Commands Match
- You can only use ufsrestore to restore files backed up with ufsdump. If you back up with tar, restore with tar. If you use the ufsrestore command to restore a tape that was written with another command, an error message tells you that the tape is not in ufsdump format.
Check to Make Sure You Have the Right Current Directory
- It is easy to restore files to the wrong location. Because the ufsdump command always copies files with full path names relative to the root of the file system, you should usually change to the root directory of the file system before running ufsrestore. If you change to a lower-level directory, after you restore the files you will see a complete file tree created under that directory.
Use the Old restore Command to Restore Multivolume Diskette Backups
- You cannot use the ufsrestore command to restore files from a multivolume backup set of diskettes made with the dump command. You must restore the files on a SunOS 4.x system.
Interactive Commands
- When you use the interactive command, a ufsrestore> prompt is displayed, as shown in this example:
-
% ufsrestore ivf /dev/rmt/0
Verify volume and initialize maps
Tape block size is 126
Dump date: Thu Aug 18 09:06:43 1994
Dumped from: Sun Aug 14 08:25:10 1994
Level 0 dump of /usr on pilgrim:/dev/dsk/c0t1d0s6
Label:none
Extract directories from tape
Initialize symbol table.
ufsrestore>
|
- At the ufsrestore> prompt, you can use the commands listed on page 786 to find files, create a list of files to be restored, and restore them.
Restoring File Systems
- Things you need to know:
-
- Which tapes have the files to be restored
- The path name of the files to be restored
· How to Determine Which Tapes to Use
-
-
Ask the user the date when the file or file system was lost, or the approximate date the files to be recovered were last modified.
-
Refer to your backup plan to find the date of the last backup that would have the file or file system on it.
Note that you do not necessarily use the most recently backed up version of the file. To retrieve the most recent version of a file, work backward through the incremental backups from highest to lowest level and most recent to least recent.
-
If you have online archive files, use the ufsrestore command to identify correct media.
-
# ufsrestore ta archive-name ./path/filename ./path/filename
|
- In this command,
-
| t | List each file that appears on the tape. |
| a | Reads the table of contents from the online archive file instead of the tape. |
| archive-name | Identifies the online archive file name. |
-
./path/filename Identifies the file name(s) you are looking for on the online archive. If successful, ufsrestore will print out the inode number and file name. If unsuccessful, ufsrestore will print an error message.
-
-
Insert the media containing the backups in the drive and use the
ufsrestore command to verify the correct media.
-
# ufsrestore tf device-name ./path/filename ./path/filename
|
- Be sure to use the complete path for the filename(s). If a file is in the backup, its name and inode number is listed. Otherwise, a message says it is not on the volume.
-
-
If you have multiple dump files on the same tape, use the s n option to position the tape at the dump you want to use.
-
# ufsrestore xfs /dev/rmt/n tape_number
|
Example--Determining Which Tapes to Use
- If you use ufsdump to dump the /usr slice, the table of contents lists only the files and directories under /usr. To see if /usr/bin/pwd is in the online archive, type:
-
# ufsrestore ta archive-name ./bin/pwd
|
- To see if /usr/bin/pwd is on the backup tape, type:
-
# ufsrestore tf /dev/rmt/n ./bin/pwd
|
· How to Restore Files Interactively
-
-
Become root.
-
Write-protect the tape.
-
Put the backup tape in the tape drive.
-
Change to a directory that will be used to restore the files temporarily.
-
- If you want to restore the files to a different directory, substitute the directory name for /var/tmp in this step.
-
-
Use the ufsrestore command to start the interactive restoration. Some informational messages and the ufsrestore> prompt are displayed.
-
ufsrestore> if /dev/rmt/n
|
-
-
Create a list of files to be restored.
a. List the contents of a directory.
-
-
b. Change to a directory.
-
ufsrestore> cd directory-name
|
-
c. Create a list of files and directories you want to restore.
-
ufsrestore> add filename filename
|
-
d. [Optional] If you need to remove a directory or file name from the list of files to be restored, use the delete command.
-
ufsrestore> delete filename
|
-
-
Turn on verbose mode to display the file names as they are being restored.
-
-
-
Use the extract command after the list is complete.
-
- The ufsrestore command asks you which volume number to use.
-
-
Type the volume number and press Return. If you have only one volume, type 1 and press Return.
-
- The files and directories in the list are extracted and restored to the current working directory.
-
-
To keep the mode of the current directory unchanged, enter n at the set owner/mode prompt.
-
set owner/mode for '.'? [yn] n
|
-
-
Quit the ufsrestore program.
-
- The shell prompt is displayed.
Verification--Restoring Files Interactively
-
-
List the restored files and directories.
-
- A list of files and directories is displayed.
-
-
Check the list to be sure all the files and directories you specified in the list have been restored.
-
Move the files to the proper directories.
Example--Restoring Files Interactively
- In this example, the files /etc/passwd and /etc/shadow are extracted from the backup tape.
-
# cd /var/tmp
# ufsrestore if /dev/rmt/0
ufsrestore> ls
.:
.OWdefaults bin lib sbin/
.Xauthority dev/ lost+found/ shared/
.desksetdefaults devices/ misc/ tmp/
.fm/ etc/ mnt/ ufsboot
.mailtool-init export/ net/ usr/
.openwin-init home/ nfs/ var/
.profile hsfsboot opt/ ws/
.wastebasket/ kadb proc/
.xsun.pluto:0 kernel/
ufsrestore> cd etc
ufsrestore> add passwd shadow
ufsrestore> verbose
verbose mode on
ufsrestore> extract
Extract requested files
You have not read any volumes yet.
Unless you know which volume your file(s) are on you should start
with the last volume and work towards the first.
Specify next volume #: 1
extract file ./etc/shadow
extract file ./etc/passwd
Add links
Set directory mode, owner, and times.
set owner/mode for '.'? [yn] n
ufsrestore> quit
#
|
· How to Restore Specific Files
-
-
Become root.
-
Write-protect the tape for safety.
-
Put the backup tape in the tape drive.
-
Change to a directory for restoring files temporarily.
-
- If you want to restore the files to a different directory, substitute the directory name for /var/tmp in this step.
-
-
Use the ufsrestore command to restore the file.
-
# ufsrestore xvf /dev/rmt/n filename
|
- In this command,
-
| x | Tells ufsrestore to copy specific files or directories in the filename argument. |
| v | Displays the file names as they are restored. |
| f /dev/rmt/n | Identifies the tape device name. |
| filename | Is one or more individual file or directory names separated by spaces, for example: ./export/home/user1/mail ./export/home/user2/mail. |
-
-
Type the volume number where files are located and press Return.
-
- The file is restored to the current working directory.
-
-
To keep the mode of the current directory unchanged, type n and press Return at the set owner/mode prompt.
-
set owner/mode for '.'? [yn] n
|
Verification--Restoring Specific Files
-
-
List the current directory.
A listing for the file is displayed.
-
-
-
Move the file to the proper directory.
-
# mv filename /directory/filename
|
Example--Restoring Specific Files
- In this example, the passwd and shadow files are restored to the /var/tmp directory.
-
# cd /var/tmp
# ufsrestore xvf /dev/rmt/0 ./etc/passwd ./etc/shadow
Verify volume and initialize maps
Media block size is 126
Dump date: Wed Oct 26 14:38:37 1994
Dumped from: the epoch
Level 0 dump of / on pluto:/dev/dsk/c0t3d0s0
Label: none
Extract directories from tape
Initialize symbol table.
Warning: ./etc: File exists
Extract requested files
You have not read any volumes yet.
Unless you know which volume your file(s) are on you should start
with the last volume and work towards the first.
Specify next volume #: 1
extract file ./etc/passwd
Add links
Set directory mode, owner, and times.
set owner/mode for '.'? [yn] n
# cd etc
# mv passwd /etc
# mv shadow /etc
# ls -l etc
|
· How to Use a Remote Drive to Restore Files
- You can restore files from a remote drive by adding remote-host: to the front of the tape device name. Here is the syntax:
-
ufsrestore rf [user@]remote-host:/dev/rmt/n filename
|
- For example, to access a remote tape drive /dev/rmt/0 on the system venus, type:
-
# ufsrestore rf venus:/dev/rmt/0 filename
|
· How to Restore a Complete File System
-
Note - You cannot use this procedure to restore / or /usr. See "How to Restore the root (/) and /usr File Systems" on page 770 for instructions on restoring these file systems.
-
-
Become root.
-
If necessary, unmount the file system.
-
# umount /dev/rdsk/device-name
|
-
-
Create the new file system with the newfs command.
-
# newfs /dev/rdsk/device-name
|
- You are asked if you want to construct a new file system on the raw device. Verify that the device-name is correct so you don't wipe out the wrong file system.
-
-
Confirm that the new file system should be created.
-
newfs: construct a new file system /dev/rdsk/cntndnsn: (y/n)? y
|
- The new file system is created.
-
-
Mount the new file system on a temporary mount point.
-
# mount /dev/dsk/device-name /mnt
|
-
-
Change to the /mnt directory.
-
- You have changed to the mount-point directory.
-
-
Write-protect the tapes.
-
Insert the first volume of the level 0 tape in the tape drive.
-
Use the ufsrestore command to restore the files on the tapes.
-
# ufsrestore rvf /dev/rmt/n
|
- The level 0 dump is restored. If the dump required multiple tapes, you will be prompted to load the next tape.
-
-
Remove the tape and load the next tape in the drive.
Always restore tapes starting with 0 and continuing until you reach the highest level.
-
-
Use the ufsrestore command to restore the file system.
-
# ufsrestore rvf /dev/rmt/n
|
- The next level tape is restored. If the dump required multiple tapes, you will be prompted to load the next tape.
-
-
Remove the restoresymtable file.
-
- The restoresymtable file created by ufsrestore is removed.
-
-
Change to another directory.
-
-
-
Unmount the newly restored file system.
-
-
-
Remove the last tape and insert a new tape that is not write-protected in the tape drive.
-
Use the ufsdump command to back up the newly restored file system.
-
# ufsdump 0uf /dev/rmt/n /dev/rdsk/device-name
|
- You should always do an immediate backup of a newly created file system because ufsrestore repositions the files and changes the inode allocation.
-
-
Mount the restored file system.
-
# mount /dev/dsk/device-name /mount-point
|
- The restored file system is mounted and available for use.
Example--Restoring a Complete File System
-
# umount /export/home
# newfs /dev/rdsk/c0t3d0s7
newfs: construct a new file system /dev/rdsk/c0t3d0s7: (y/n)? y
/dev/rdsk/c0t3d0s7:41040 sectors in 57 cylinders of 9 tracks, 80
sectors
21.0MB in 4 cyl groups (16 c/g, 5.90MB/g, 2688 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 11632, 23232, 34832,
# mount /dev/dsk/c0t3d0s7 /mnt
# cd /mnt
# ufsrestore rvf /dev/rmt/0
Verify volume and initialize maps
Media block size is 126
Dump date: Fri Oct 28 11:00:30 1994
Dumped from: the epoch
Level 0 dump of /export/home on skisun:/dev/dsk/c0t3d0s7
Label: none
Begin level 0 restore
Initialize symbol table.
Extract directories from tape
Calculate extraction list.
Warning: ./lost+found: File exists
Make node ./kryten
Make node ./kryten/letters
Make node ./kryten/memos
Make node ./kryten/reports
Make node ./rimmer
Make node ./rimmer/sc.directives
Make node ./rimmer/tests
Make node ./rimmer/answers
Extract new leaves.
Check pointing the restore
# rm restoresymtable
# cd /
# umount /mnt
# ufsdump 0ucf /dev/rmt/0 /export/home
.
.
.
# mount /dev/dsk/c0t3d0s7 /export/home
# ls /export/home
|
· How to Restore the root (/) and /usr File Systems
-
-
Add a new system disk to the system where the root (/) and /usr file systems will be restored.
For a detailed description about adding a system disk, refer to Chapter 29, "SPARC: Adding a Disk," or Chapter 30, "x86: Adding a Disk."
-
Mount the new file system on a temporary mount point.
-
# mount /dev/dsk/device-name /mnt
|
-
-
Change to the /mnt directory.
-
-
-
Create the tape device entries.
-
-
-
Write-protect the tapes.
-
Use the ufsrestore command to restore the root file system.
-
# ufsrestore rvf /dev/rmt/n
|
- The level 0 tape is restored.
-
-
Remove the tape and load the next level tape in the drive.
Always restore tapes starting with 0 and continuing from lowest to highest level.
-
Continue to use the ufsrestore command as needed.
-
# ufsrestore rvf /dev/rmt/n
|
- The next level tape is restored.
-
-
Repeat steps 7 and 8 for each additional tape.
-
-
Remove the restoresymtable file.
-
- Removes the restoresymtable file that is created and used by ufsrestore to check point the restore.
-
-
Change to the root (/) directory.
-
-
-
Unmount the newly created file system.
-
-
-
Check the new file system.
-
# fsck /dev/rdsk/device-name
|
- The restored file system is checked for consistency.
-
-
Insert a new tape in the tape drive.
-
Back up the new file system.
-
# ufsdump 0uf /dev/rmt/n /dev/rdsk/device-name
|
- A level 0 backup is performed. Always do an immediate backup of a newly created file system because ufsrestore repositions the files and changes the inode allocation.
-
-
Repeat steps 5 through 18 for the /usr file system, if necessary.
-
-
Reboot the system.
-
- The system is rebooted.
Example--Restoring the root (/) File System
-
mount /dev/dsk/c0t3d0s0 /mnt
# cd /mnt
# umount /mnt
# tapes
# ufsrestore rvf /dev/rmt/0
# rm restoresymtable
# cd /
# umount /mnt
# fsck /dev/rdsk/c0t3d0s0
# ufsdump 0uf /dev/rmt/0 /dev/rdsk/c0t3d0s0
# init 6
|
|
|