Chapter 48 Restoring Files and File Systems (Tasks)
This chapter describes how to use the ufsrestore command to restore files and file systems that were backed up by
using the ufsdump command.
For information on the procedures associated with restoring files and
file systems, see Restoring Files and File System Backups (Task Map).
For information about other commands you can use to archive, restore,
copy, or move files and file systems, see Chapter 50, Copying UFS Files and File Systems (Tasks).
Restoring Files and File System Backups (Task Map)
The following task map describes the procedures associated with restoring
files and file systems.
Preparing to Restore Files and File Systems
The ufsrestore command copies files to
disk, relative to the current working directory, from backups that were created
by using the ufsdump command. You can use the ufsrestore command 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 backup tape. If the ufsrestore command
is run as superuser, 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
the following:
-
The tapes (or diskettes) you need
-
The raw device name on which you want to restore the file
system
-
The type of tape device you will use
-
The device name (local or remote) for the tape drive
Determining the File System Name
If you have properly labeled your backup tapes, you should
be able to use the file system name (/dev/rdsk/device-name) from the tape label. For more information, see How to Find File System Names.
Determining the Type of Tape Device You Need
You must use a tape device 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 might 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. For more information on media devices and device names, see Chapter 51, Managing Tape Drives (Tasks).
Restoring Files and File Systems
When you back up files and directories, you save them relative to the
file system in which they belong. When you restore files and directories,
the ufsrestore command re-creates the file hierarchy in
the current working directory.
For example, files backed up from the /export/doc/books
directory (where /export is the file system), are saved
relative to /export. In other words, the book1 file in the books directory is saved as ./doc/books/book1 on the tape. Later on, if you restored the ./doc/books/book1 file to the /var/tmp directory,
the file would be restored to /var/tmp/doc/books/book1.
When you restore individual files and directories, it is a good idea
to restore them to a temporary location, such as the /var/tmp
directory. 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.
To avoid conflicts with other users, you might want to create and change
to a subdirectory, such as the/var/tmp/restore file,
in which to restore the files.
If you are restoring a hierarchy, you should restore the files in a
temporary directory on the same file system where the files will reside. So,
you can use the mv command to move the entire hierarchy
where it belongs after it is restored.
Note –
Do not restore files in the /tmp directory
even temporarily. The /tmp directory is usually mounted
as a TMPFS file system and TMPFS does not support UFS file system attributes
such as ACLs.
How to Determine Which Tapes to Use
-
Ask the user for the approximate date the files to be restored were
last modified.
-
Refer to your backup plan to find the date of the last backup that contains
the file or file system.
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, unless the user requests otherwise.
-
(Optional) If you have online archive files, identify the correct media.
# ufsrestore ta archive-name ./path/filename ./path/filename
|
|
t
|
Lists each file 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,
the ufsrestore command prints out the inode number and
file name. If unsuccessful, ufsrestore prints an error
message.
|
For more information, see ufsrestore(1M).
-
Insert the media that contains the files to be restored in the drive
and verify the correct media.
# ufsrestore tf /dev/rmt/n ./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 that the file is not on the volume.
-
(Optional) If you have multiple dump files on the same tape, position
the tape at the dump file you want to use.
# ufsrestore tfs /dev/rmt/n tape-number
|
Examples—Determining Which Tapes to Use
The following example shows how to checks if /etc/passwd
file is in the online archive.
# ufsrestore ta /var/tmp/root.archive ./etc/passwd
|
The following example show to verify that the /etc/passwd is on the backup tape.
# ufsrestore tf /dev/rmt/0 ./etc/passwd
|
How to Restore Files Interactively
-
Become superuser or assume an equivalent role.
-
(Optional) Write-protect the tape for safety.
-
Insert the volume 1 tape into the tape drive.
-
Change to a directory that will be used to restore the files temporarily.
-
Start the interactive restoration.
# ufsrestore if /dev/rmt/n
|
Some informational messages and the ufsrestore> prompt
are displayed.
-
Create a list of files to be restored.
-
List the contents of a directory.
-
Change to a directory.
ufsrestore> cd directory-name
|
-
Create a list of files and directories that you want to restore.
ufsrestore> add filename filename
|
-
(Optional) (Optional) Remove any directory or file name from the list of files
to be restored, if necessary.
ufsrestore> delete filename
|
-
(Optional) (Optional) Display the file names as they are being restored.
-
Restore the files.
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
|
You must wait while the ufsrestore command performs
its final cleanup.
-
Quit the ufsrestore program.
You then see the shell prompt.
-
Verify the restored files.
-
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
The following example shows how to extract the /etc/passwd and /etc/shadow files from the backup tape.
# cd /var/tmp
# ufsrestore if /dev/rmt/0
ufsrestore> ls
.:
.cpr_config etc/ lost+found/ sbin/ usr/
TT_DB/ export/ mnt/ sccs/ var/
b/ home/ net/ share/ vol/
bin kernel/ opt/ shared/ ws/
dev/ lib platform/ src/ xfn/
devices/ license/ proc/ tmp/
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 Non-Interactively
-
Become superuser or assume an equivalent role.
-
(Optional) Write-protect the tape for safety.
-
Insert the volume 1 tape into the tape drive.
-
Change to a directory that will be used to restore files temporarily.
-
Restore the file or files.
# ufsrestore xvf /dev/rmt/n filename
|
|
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
|
Specifies one or more
individual file names 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 or files are 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
|
-
Verify the restored files.
-
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 Specific Files Non-Interactively
The following example shows how to restore the passwd
and shadow files 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 Dec 12 10:54:45 2001
Dumped from: the epoch
Level 0 dump of / on earth:/dev/dsk/c0t1d0s0
Label: none
Extract directories from tape
Initialize symbol table.
Make node ./etc
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
extract file ./etc/shadow
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
|
Example—Restoring Files From a Remote Tape Device
You can
restore files from a remote tape drive by adding remote-host: to the front of the tape device name, when
using the ufsrestore command.
The following example shows how to restore files using a remote tape
drive /dev/rmt/0 on the system venus.
# ufsrestore xf venus:/dev/rmt/0 ./etc/hosts
|
How to Restore a Complete File System
Occasionally, a file system becomes so damaged that you must completely
restore it. Typically, you need to restore a complete file system after a
disk failure. You might need to replace the hardware before you can restore
the software. For information on how to replace a disk, see Chapter 33, SPARC: Adding a Disk (Tasks)
or Chapter 34, x86: Adding a Disk (Tasks). Full restoration of a file system such
as /export/home can take a lot of time. If you have consistently
backed up file systems, you can restore them to their state from the time
of the last incremental backup.
Note –
You cannot use this procedure to restore the root (/) or /usr file systems. For instructions
on restoring these file systems, see How to Restore the root (/) and /usr File Systems.
-
Become superuser or assume an equivalent role.
-
If necessary, unmount the file system.
# umount /dev/rdsk/device-name
|
-
Create the new file system.
# 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 destroy the wrong file system.
For more information, see newfs(1M).
-
Confirm that the new file system should be created.
newfs: construct a new file system /dev/rdsk/cwtxdysz:(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 mount point directory.
-
(Optional) Write-protect the tapes for safety.
-
Insert the first volume of the level 0 tape into the tape drive.
-
Restore the files.
# ufsrestore rvf /dev/rmt/n
|
The level 0 dump is restored. If the dump required multiple tapes, you
are prompted to load each tape in numeric order.
-
Remove the tape and load the next level tape in the drive.
Always restore tapes starting with 0 and continuing until you reach
the highest level.
-
Repeat Step 8 through Step 10
for each dump level, from the lowest to the highest level.
-
Verify that the file system is restored.
-
Remove the restoresymtable file.
The restoresymtable file that is created and used
by the ufsrestore command to check-point the restore 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.
-
Make a level 0 backup of the newly restored 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.
-
Mount the restored file system.
# mount /dev/dsk/device-name mount-point
|
The restored file system is mounted and available for use.
-
Verify that the restored and mounted file system is available.
Example—Restoring a Complete File System
The following example shows how to restore the /export/home file system.
# umount /export/home
# newfs /dev/rdsk/c0t3d0s7
newfs: construct a new file system /dev/rdsk/c0t3d0s7: (y/n)? y
/dev/rdsk/c0t3d0s7: 410400 sectors in 270 cylinders of 19 tracks,
80 sectors
200.4MB in 17 cyl groups (16 c/g, 11.88MB/g, 5696 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 24432, 48832, 73232, 97632, 122032, 146432, 170832, 195232, 219632,
244032, 268432, 292832, 317232, 341632, 366032, 390432,
# mount /dev/dsk/c0t3d0s7 /mnt
# cd /mnt
# ufsrestore rvf /dev/rmt/0
Verify volume and initialize maps
Media block size is 126
Dump date: Sat Jul 14 08:49:33 2001
Dumped from: the epoch
Level 0 dump of /export/home on earth:/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/reports
Extract new leaves.
Check pointing the restore
extract file ./kryten/.cshrc
extract file ./kryten/.login
extract file ./kryten/b
extract file ./kryten/memos
extract file ./kryten/letters/b
extract file ./kryten/letters/letter1
extract file ./kryten/letters/letter2
extract file ./kryten/letters/letter3
extract file ./kryten/reports/reportA
extract file ./kryten/reports/reportB
extract file ./kryten/reports/reportC
Add links
Set directory mode, owner, and times.
Check the symbol table.
Check pointing the restore
# ls
# 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
-
Become superuser or assume an equivalent role.
-
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 33, SPARC: Adding a Disk (Tasks) or Chapter 34, x86: Adding a Disk (Tasks).
-
Mount the new file system on a temporary mount point.
# mount /dev/dsk/device-name /mnt
|
-
Change to the /mnt directory.
-
(Optional) Write-protect the tapes for safety.
-
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 dump level 0 and continuing from
lowest to highest level.
-
Continue restoring as needed.
# ufsrestore rvf /dev/rmt/n
|
The next level tape is restored.
-
Repeat Step 7 and Step 8
for each additional tape.
-
Verify the file system is restored.
-
Remove the restoresymtable file.
The restoresymtable file that is created and used
by the ufsrestore command to check-point the restore is
removed.
-
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.
-
Create the boot blocks on the root partition.
# installboot /usr/platform/`uname-i`/lib/fs/ufs/bootblk
/dev/rdsk/device-name
|
For more information, see installboot(1M).
For an example of using the installboot command on
a SPARC based system, see SPARC: Example—Restoring the root (/) File System. For an example
of using the installboot command on an IA based system,
see x86: Example—Restoring the root (/) File System.
-
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 16 for the /usr file system,
if necessary.
-
Reboot the system.
The system is rebooted.
SPARC: Example—Restoring the root (/) File System
This example shows how to restore the root (/)
file system on a SPARC system. This example assumes that the system is booted
from a local CD or from the network.
# mount /dev/dsk/c0t3d0s0 /mnt
# cd /mnt
# tapes
# ufsrestore rvf /dev/rmt/0
# ls
# rm restoresymtable
# cd /
# umount /mnt
# fsck /dev/rdsk/c0t3d0s0
# installboot /usr/platform/sun4m/lib/fs/ufs/bootblk /dev/rdsk/c0t3d0s0
# ufsdump 0uf /dev/rmt/0 /dev/rdsk/c0t3d0s0
# init 6
|
x86: Example—Restoring the root (/) File System
This example shows how to restore the root (/)
file system on a IA system. This example assumes that the system is booted
from a local CD or from the network.
# mount /dev/dsk/c0t3d0s0 /mnt
# cd /mnt
# tapes
# ufsrestore rvf /dev/rmt/0
# ls
# rm restoresymtable
# cd /
# umount /mnt
# fsck /dev/rdsk/c0t3d0s0
# installboot /usr/platform/`uname -i`/lib/fs/ufs/pboot /usr/platform/`uname -i`/lib/fs/
ufs/bootblk /dev/rdsk/c0t3d0s2
# ufsdump 0uf /dev/rmt/0 /dev/rdsk/c0t3d0s0
# init 6
|