<chapter id="bkuprestoretasks-38055"><title>Restoring
Files and File Systems (Tasks)</title><highlights><para>This chapter describes how to use the <command>ufsrestore</command> command
to restore files and file systems that were backed up by using the <command>ufsdump</command> command. </para><para>For information on the procedures associated with restoring files and
file systems, see <olink targetptr="bkuprestoretasks-3" remap="internal">Restoring Files and
File System Backups (Task Map)</olink>.</para><para>For information about other commands you can use to archive, restore,
copy, or move files and file systems, see <olink targetptr="bkupsavefiles-17924" remap="internal">Chapter&nbsp;28, Copying UFS Files and File Systems (Tasks)</olink>.</para><para>For information about backing up and restoring file systems, see <olink targetptr="bkupconcepts-57422" remap="internal">Chapter&nbsp;23, Backing Up and Restoring File Systems (Overview)</olink>.</para>
</highlights><sect1 id="bkuprestoretasks-3"><title>Restoring Files and File System Backups
(Task Map)</title><para>The following task map describes the procedures associated with restoring
files and file systems.</para><informaltable frame="all"><tgroup cols="3" colsep="1" rowsep="1"><colspec colname="colspec2" colwidth="110*"/><colspec colname="col2" colwidth="167*"/><colspec colname="colspec3" colwidth="119*"/><thead><row><entry><para>Task</para>
</entry><entry><para>Description</para>
</entry><entry><para>For Instructions</para>
</entry>
</row>
</thead><tbody><row><entry><para>Prepare to restore files and file systems.</para>
</entry><entry><para>Identify the file systems or files to be restored, the tape device,
and how you will restore them.</para>
</entry><entry><para><olink targetptr="bkuprestoretasks-1" remap="internal">Preparing to Restore Files and
File Systems</olink></para>
</entry>
</row><row><entry><para>Determine which tapes to use.</para>
</entry><entry><para>Refer to your backup tapes to find the date of the last backup that
contains the file or file system that you need to restore.</para>
</entry><entry><para><olink targetptr="bkuprestoretasks-40591" remap="internal">How to Determine Which Tapes
to Use</olink></para>
</entry>
</row><row><entry rowsep="0"><para>Restore files.</para>
</entry><entry rowsep="0"><para>Choose one of the following restore methods:</para>
</entry><entry rowsep="0"><para></para>
</entry>
</row><row><entry rowsep="0"><para></para>
</entry><entry rowsep="0"><para>Restore files interactively &ndash; Use this method when you are unsure
of the file names because you can browse the media contents and select individual
files and directories.</para>
</entry><entry rowsep="0"><para><olink targetptr="bkuprestoretasks-63510" remap="internal">How to Restore Files Interactively</olink></para>
</entry>
</row><row><entry rowsep="0"><para></para>
</entry><entry rowsep="0"><para>Restore files noninteractively &ndash; Use this method when you already
  know the few file names to be restored.</para>
</entry><entry rowsep="0"><para><olink targetptr="bkuprestoretasks-72504" remap="internal">How to Restore Specific Files
Noninteractively</olink></para>
</entry>
</row><row><entry rowsep="1"><para></para>
</entry><entry rowsep="1"><para>Restore a file system &ndash; Use this method when you get a new disk
drive or as part of a recovery procedure.</para>
</entry><entry rowsep="1"><para><olink targetptr="bkuprestoretasks-65439" remap="internal">How to Restore a Complete
File System</olink></para>
</entry>
</row><row><entry><para>Restore the root (<filename>/</filename>) or <filename>/usr</filename> file
systems.</para>
</entry><entry><para>Restoring the root (<filename>/</filename>) or <filename>/usr</filename> file
systems involves booting the system from a local CD or the network.</para>
</entry><entry><para><olink targetptr="bkuprestoretasks-87945" remap="internal">How to Restore the root (/)
and /usr File Systems</olink></para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</sect1><sect1 id="bkuprestoretasks-1"><title>Preparing to Restore Files and File
Systems</title><para>The <command>ufsrestore</command> command copies files to disk,
relative to the current working directory, from backups that were created
by using the <command>ufsdump</command> command. You can use the <command>ufsrestore</command> command to reload an entire file system hierarchy from a level
0 dump and incremental dumps that follow it. You can also use this command
to restore one or more single files from any backup tape. If you run the <command>ufsrestore</command> command as superuser, files are restored with their original
owner, last modification time, and mode (permissions). </para><para>Before you start to restore files or file systems, you need to know
the following:</para><itemizedlist><listitem><para>The tapes (or diskettes) you need to restore from</para>
</listitem><listitem><para>The raw device name on which you want to restore the file
system</para>
</listitem><listitem><para>The type of tape device you will use</para>
</listitem><listitem><para>The device name (local or remote) for the tape device</para>
</listitem>
</itemizedlist><sect2 id="bkuprestoretasks-2"><title>Determining the File System Name</title><para>If you have properly labeled your backup tapes, you should be able to
use the file system name (<filename>/dev/rdsk/</filename><replaceable>device-name</replaceable>) from the tape label. For more information, see <olink targetptr="bkuptasks2-78540" remap="internal">How to Find File System Names</olink>.</para>
</sect2><sect2 id="bkuprestoretasks-5"><title>Determining the Type of Tape Device
You Need</title><para>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 device to restore the files.</para>
</sect2><sect2 id="bkuprestoretasks-4"><title>Determining the Tape Device Name</title><para>You might have specified the tape device name (<filename>/dev/rmt/</filename><replaceable>n</replaceable>) 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 <olink targetptr="bkuptapedevice-42512" remap="internal">Chapter&nbsp;29, Managing Tape Drives (Tasks)</olink>.</para>
</sect2>
</sect1><sect1 id="bkuprestoretasks-10"><title>Restoring Files and File Systems</title><para>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 <command>ufsrestore</command> command re-creates the file hierarchy in
the current working directory.</para><para>For example, files backed up from the <filename>/export/doc/books</filename> directory
(where <filename>/export</filename> is the file system) are saved relative
to <filename>/export</filename>. In other words, the <filename>book1</filename> file
in the <filename>books</filename> directory is saved as <filename>./doc/books/book1</filename> on the tape. Later on, if you restored the <filename>./doc/books/book1</filename> file to the <filename>/var/tmp</filename> directory, the file
would be restored to <filename>/var/tmp/doc/books/book1</filename>.</para><para>When you restore individual files and directories, you should restore
them to a temporary location, such as the <filename>/var/tmp</filename> directory.
After you verify the files, you can move them to their proper locations. However,
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.</para><para>To avoid conflicts with other users, you might want to create and change
to a subdirectory, such as the<filename>/var/tmp/restore</filename> file,
in which to restore the files.</para><para>If you are restoring a hierarchy, you should restore the files to a
temporary directory on the same file system where the files will reside. Then,
you can use the <command>mv</command> command to move the entire hierarchy
where it belongs after it is restored.</para><note><para>Do not restore files in the <filename>/tmp</filename> directory
even temporarily. The <filename>/tmp</filename> directory is usually mounted
as a TMPFS file system. TMPFS does not support UFS file system attributes
such as ACLs.</para>
</note><task id="bkuprestoretasks-40591"><title>How to Determine Which Tapes to Use</title><procedure><step id="bkuprestoretasks-step-12"><para>Ask the user for the approximate
date the files to be restored were last modified.</para>
</step><step id="bkuprestoretasks-step-13"><para>Refer to your backup plan to find
the date of the last backup that contains the file or file system.</para><para>To
retrieve the most recent version of a file, work backward through the incremental
backups from highest to lowest dump level and from most recent to least recent
date, unless the user requests otherwise.</para>
</step><step id="bkuprestoretasks-step-14"><para>If you have online archive files,
identify the correct media.</para><screen># <userinput>ufsrestore ta</userinput> <replaceable>archive-name</replaceable> <replaceable>./path/filename ./path/filename</replaceable></screen><variablelist><varlistentry><term><command>t</command></term><listitem><para>Lists each file on the tape.</para>
</listitem>
</varlistentry><varlistentry><term><command>a</command></term><listitem><para>Reads the table of contents from the online archive file instead
of from the tape.</para>
</listitem>
</varlistentry><varlistentry><term><replaceable>archive-name</replaceable></term><listitem><para>Identifies the online archive file name.</para>
</listitem>
</varlistentry><varlistentry><term><replaceable>./path/</replaceable><emphasis>filename</emphasis></term><listitem><para>Identifies the file name or file names you are looking for
on the online archive. If successful, the <command>ufsrestore</command> command
prints out the inode number and file name. If unsuccessful, <command>ufsrestore</command> 
prints an error message.</para>
</listitem>
</varlistentry>
</variablelist><para>For more information, see the <olink targetdoc="refman1m" targetptr="ufsrestore-1m" remap="external"><citerefentry><refentrytitle>ufsrestore</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink> man page.</para>
</step><step id="bkuprestoretasks-step-15"><para>Insert the media that contains the
files to be restored in the drive and verify the correct media.</para><screen># <userinput>ufsrestore tf /dev/rmt/</userinput><replaceable>n ./path/filename ./path/filename</replaceable></screen><para>Be sure to use the complete path for each <replaceable>filename</replaceable>.
If a file is in the backup, its name and inode number are listed. Otherwise,
a message states that the file is not on the volume.</para>
</step><step id="bkuprestoretasks-step-16"><para>If you have multiple backup files
on the same tape, position the tape at the backup file you want to use.</para><screen># <userinput>ufsrestore xfs /dev/rmt/</userinput><replaceable>n</replaceable> <replaceable>tape-number</replaceable></screen>
</step>
</procedure><example id="fncrp"><title>Determining Which Tapes to Use</title><para>The following example shows how to check if the <filename>/etc/passwd</filename> file
is in the online archive.</para><screen># <userinput>ufsrestore ta /var/tmp/root.archive ./etc/passwd</userinput></screen><para>The following example shows how to verify that the <filename>/etc/passwd</filename> file
is on the backup tape.</para><screen># <userinput>ufsrestore tf /dev/rmt/0 ./etc/passwd</userinput></screen>
</example>
</task><task id="bkuprestoretasks-63510"><title>How to Restore Files Interactively</title><procedure><step id="bkuprestoretasks-step-19"><para>Become superuser or assume an equivalent
role.</para>
</step><step id="bkuprestoretasks-step-20"><para>(Optional) Write-protect the tapes
for safety.</para>
</step><step id="bkuprestoretasks-step-21"><para>Insert the volume 1 tape into the
tape drive.</para>
</step><step id="bkuprestoretasks-step-22"><para>Change to a directory that will
be used to restore the files to temporarily.</para><screen># <userinput>cd /var/tmp</userinput></screen>
</step><step id="bkuprestoretasks-step-23"><para>Start the interactive restoration.</para><screen># <userinput>ufsrestore if /dev/rmt/</userinput><replaceable>n</replaceable></screen><para>Some informational messages and the <literal>ufsrestore></literal> prompt
are displayed.</para>
</step><step id="bkuprestoretasks-step-24"><para>Create a list of files to be restored.</para><substeps><step id="bkuprestoretasks-step-25"><para>List the contents of a directory.</para><screen>ufsrestore> <userinput>ls</userinput> [<replaceable>directory-name</replaceable>]</screen>
</step><step id="bkuprestoretasks-step-26"><para>Change to a directory.</para><screen>ufsrestore> <userinput>cd</userinput> <replaceable>directory-name</replaceable></screen>
</step><step id="bkuprestoretasks-step-27"><para>Create a list of files and directories
that you want to restore.</para><screen>ufsrestore> <userinput>add</userinput> <replaceable>filenames</replaceable></screen>
</step><step performance="optional" id="bkuprestoretasks-step-28"><para>Remove any
directory or file from the list of files to be restored, if necessary.</para><screen>ufsrestore> <userinput>delete</userinput> <replaceable>filename</replaceable></screen>
</step>
</substeps>
</step><step performance="optional" id="bkuprestoretasks-step-29"><para>Display the
file names as they are being restored.</para><screen>ufsrestore> <userinput>verbose</userinput></screen>
</step><step id="bkuprestoretasks-step-30"><para>Restore the files.</para><screen>ufsrestore> <userinput>extract</userinput></screen><para>The <command>ufsrestore</command> command asks you which volume number
to use.</para>
</step><step id="bkuprestoretasks-step-31"><para>Type the volume number and press
Return. If you have only one volume, type <command>1</command> and press Return.</para><screen>Specify next volume #: <userinput>1</userinput></screen><para>The files and directories in the list are extracted and restored to
the current working directory.</para>
</step><step id="bkuprestoretasks-step-32"><para>To maintain the mode of the current
directory, enter <command>n</command> at the  <literal>set owner/mode</literal> prompt.</para><screen>set owner/mode for `.'? [yn] <userinput>n</userinput></screen><para>You must wait while the <command>ufsrestore</command> command performs
its final cleanup.</para>
</step><step id="bkuprestoretasks-step-33"><para>Quit the <command>ufsrestore</command> program.</para><screen>ufsrestore> <userinput>quit</userinput></screen><para>You then see the shell prompt.</para>
</step><step id="bkuprestoretasks-step-92"><para>Verify the restored files.</para><substeps><step id="bkuprestoretasks-step-97"><para>List the restored files and directories.</para><screen># <userinput>ls -l</userinput></screen><para>A list of files and directories is displayed.</para>
</step><step id="bkuprestoretasks-step-98"><para>Check the list to be sure that all
the files and directories you specified in the list have been restored.</para>
</step>
</substeps>
</step><step id="bkuprestoretasks-step-99"><para>Move the files to the proper directories.</para>
</step>
</procedure><example id="fncrq"><title>Restoring Files Interactively</title><para>The following example shows how to extract the <filename>/etc/passwd</filename> and <filename>/etc/shadow</filename> files from the backup tape.</para><screen># <userinput>cd /var/tmp</userinput>
# <userinput>ufsrestore if /dev/rmt/0</userinput>
ufsrestore> <userinput>ls</userinput>
.:
 .:
 .sunw/        export/       net/          sbin/         usr/
 Sources/      etools/       opt/          scde/         var/
 b/            home/         ptools/       set/          vol/
 bin           kernel/       pkg/          share/        
 dev/          lib/          platform/     shared/
 devices/      lost+found/   proc/         src/
 etc/          mnt/          rtools/       tmp/
ufsrestore> <userinput>cd etc</userinput>
ufsrestore> <userinput>add passwd shadow</userinput>
ufsrestore> <userinput>verbose</userinput>
verbose mode on
ufsrestore> <userinput>extract</userinput>
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 #: <userinput>1</userinput>
extract file ./etc/shadow
extract file ./etc/passwd
Add links
Set directory mode, owner, and times.
set owner/mode for `.'? [yn] <userinput>n</userinput>
ufsrestore> <userinput>quit</userinput>
# <userinput>cd etc</userinput>
# <userinput>mv passwd /etc</userinput>
# <userinput>mv shadow /etc</userinput>
# <userinput>ls -l /etc</userinput></screen>
</example>
</task><task id="bkuprestoretasks-72504"><title>How to Restore Specific Files Noninteractively</title><procedure><step id="bkuprestoretasks-step-41"><para>Become superuser or assume an equivalent
role.</para>
</step><step id="bkuprestoretasks-step-42"><para>(Optional) Write-protect the tape
for safety.</para>
</step><step id="bkuprestoretasks-step-43"><para>Insert the volume 1 tape into the
tape drive.</para>
</step><step id="bkuprestoretasks-step-44"><para>Change to a directory that will
be used to restore files to temporarily.</para><screen># <userinput>cd /var/tmp</userinput></screen>
</step><step id="bkuprestoretasks-step-45"><para>Restore the file or files.</para><screen># <userinput>ufsrestore xvf /dev/rmt/</userinput><replaceable>n</replaceable> <replaceable>filename</replaceable></screen><variablelist><varlistentry><term><command>x</command></term><listitem><para>Tells <command>ufsrestore</command> to copy specific files
or directories in the <replaceable>filename</replaceable> argument.</para>
</listitem>
</varlistentry><varlistentry><term><command>v</command></term><listitem><para>Displays the file names as they are restored.</para>
</listitem>
</varlistentry><varlistentry><term><filename>f /dev/rmt/</filename><replaceable>n</replaceable></term><listitem><para>Identifies the tape device name.</para>
</listitem>
</varlistentry><varlistentry><term><emphasis>filename</emphasis></term><listitem><para>Specifies one or more file names or directory names, separated
by spaces. For example: <filename>./export/home/user1/mail</filename> <filename>./export/home/user2/mail</filename>.</para>
</listitem>
</varlistentry>
</variablelist>
</step><step id="bkuprestoretasks-step-46"><para>Type the volume number where files
are located. Press Return.</para><screen>Specify next volume #: <userinput>1</userinput></screen><para>The file or files are restored to the current working directory.</para>
</step><step id="bkuprestoretasks-step-47"><para>To maintain the mode of the current
directory, type <command>n</command> and press Return at the <literal>set
owner/mode</literal> prompt.</para><screen>set owner/mode for '.'? [yn] <userinput>n</userinput></screen>
</step><step id="bkuprestoretasks-step-93"><para>Verify the restored files.</para><substeps><step id="bkuprestoretasks-step-3"><para>List the restored files and directories.</para><screen># <userinput>ls -l</userinput></screen><para>A list of files and directories is displayed.</para>
</step><step id="bkuprestoretasks-step-4"><para>Check the list to be sure that all
the files and directories you specified in the list have been restored.</para>
</step>
</substeps>
</step><step id="bkuprestoretasks-step-5"><para>Move the files to the proper directories.</para>
</step>
</procedure><example id="fncro"><title>Restoring Specific Files Noninteractively</title><para>The following example shows how to noninteractively restore the <command>passwd</command> and <command>shadow</command> files to the <filename>/var/tmp</filename> directory. </para><screen># <userinput>cd /var/tmp</userinput>
# <userinput>ufsrestore xvf /dev/rmt/0 ./etc/passwd ./etc/shadow</userinput>
Verify volume and initialize maps
Media block size is 126
Dump   date: Wed Jul 28 16:13:52 2004
Dumped from: the epoch
Level 0 dump of / on starbug:/dev/dsk/c0t0d0s0
Label: none
Extract directories from tape
Initialize symbol table.
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.
Specify next volume #:<userinput>1</userinput>
extract file ./etc/passwd
extract file ./etc/shadow
Add links
Set directory mode, owner, and times.
set owner/mode for `.'? [yn] <userinput>n</userinput>
# <userinput>cd etc</userinput>
# <userinput>mv passwd /etc</userinput>
# <userinput>mv shadow /etc</userinput>
# <userinput>ls -l /etc</userinput></screen>
</example><example id="fncrs"><title>Restoring Files From a Remote Tape Device</title><para>You can restore files from a remote tape drive by adding <replaceable>remote-host</replaceable><command>:</command> to the front of the tape device name, when
using the <command>ufsrestore</command> command.</para><para>The following example shows how to restore files by using a remote tape
drive <filename>/dev/rmt/0</filename> on the system <literal>venus</literal>.</para><screen># <userinput>ufsrestore xf venus:/dev/rmt/0 ./etc/hosts</userinput></screen>
</example>
</task><task id="bkuprestoretasks-65439"><title>How to Restore a Complete File System</title><tasksummary><para>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 <olink targetptr="diskssadd-53" remap="internal">Adding a System Disk or a Secondary Disk (Task Map)</olink> or <olink targetptr="disksxadd-73" remap="internal">Adding a System Disk or a Secondary Disk (Task Map)</olink>.</para><para>Full restoration of a file system such as <filename>/export/home</filename> 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.</para><note><para>You cannot use this procedure to restore the root (<filename>/</filename>)
or <filename>/usr</filename> file systems. For instructions on restoring these
file systems, see <olink targetptr="bkuprestoretasks-87945" remap="internal">How to Restore
the root (/) and /usr File Systems</olink>.</para>
</note>
</tasksummary><procedure><step id="bkuprestoretasks-step-54"><para>Become superuser or assume an equivalent role. </para>
</step><step id="bkuprestoretasks-step-55"><para>If necessary, unmount the file system. </para><screen># <userinput>umount /dev/rdsk/</userinput><replaceable>device-name</replaceable></screen><para>Or:</para><screen># <userinput>umount</userinput> <replaceable>/file-system</replaceable></screen>
</step><step id="bkuprestoretasks-step-56"><para>Create the new file system.</para><screen># <userinput>newfs /dev/rdsk/</userinput><replaceable>device-name</replaceable></screen><para>You are asked if you want to construct a new file system on the raw
device. Verify that the <replaceable>device-name</replaceable> is correct
so that you don't destroy the wrong file system.</para><para>For more information,
see the <olink targetdoc="refman1m" targetptr="newfs-1m" remap="external"><citerefentry><refentrytitle>newfs</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink> man
page.</para>
</step><step id="bkuprestoretasks-step-57"><para>Confirm that the new file system
should be created.</para><screen>newfs: construct a new file system /dev/rdsk/c<replaceable>w</replaceable>t<replaceable>x</replaceable>d<replaceable>y</replaceable>s<replaceable>z</replaceable>:(y/n)? <userinput>y</userinput></screen><para>The new file system is created.</para>
</step><step id="bkuprestoretasks-step-58"><para>Mount the new file system on a temporary
mount point.</para><screen># <userinput>mount /dev/dsk/</userinput><replaceable>device-name</replaceable> <userinput>/mnt</userinput></screen>
</step><step id="bkuprestoretasks-step-59"><para>Change to the mount point directory.</para><screen># <userinput>cd /mnt</userinput></screen>
</step><step id="bkuprestoretasks-step-60"><para>(Optional) Write-protect the tapes
for safety.</para>
</step><step id="bkuprestoretasks-step-61"><para>Insert the first volume of the level
0 tape into the tape drive.</para>
</step><step id="bkuprestoretasks-step-62"><para>Restore the files.</para><screen># <userinput>ufsrestore rvf /dev/rmt/</userinput><replaceable>n</replaceable></screen><para>The dump level 0 backup is restored. If the backup required multiple
tapes, you are prompted to load each tape in numeric order.</para>
</step><step id="bkuprestoretasks-step-63"><para>Remove the tape and load the next
level tape in the drive.</para><para>Always restore tapes starting with dump
level 0 and continuing until you reach the highest dump level. </para>
</step><step id="bkuprestoretasks-step-64"><para>Repeat <olink targetptr="bkuprestoretasks-step-61" remap="internal">Step&nbsp;8</olink> through <olink targetptr="bkuprestoretasks-step-63" remap="internal">Step&nbsp;10</olink> for each dump level,
from the lowest to the highest level.</para>
</step><step id="bkuprestoretasks-step-94"><para>Verify that the file system has
been restored.</para><screen># <userinput>ls</userinput></screen>
</step><step id="bkuprestoretasks-step-65"><para>Remove the <filename>restoresymtable</filename> file.</para><screen># <userinput>rm restoresymtable</userinput></screen><para>The <filename>restoresymtable</filename> file that is created and used
by the <command>ufsrestore</command> command to check-point the restore is
removed.</para>
</step><step id="bkuprestoretasks-step-66"><para>Change to another directory.</para><screen># <userinput>cd /</userinput></screen>
</step><step id="bkuprestoretasks-step-67"><para>Unmount the newly restored file
system.</para><screen># <userinput>umount /mnt</userinput></screen>
</step><step id="bkuprestoretasks-step-68"><para>Remove the last tape and insert
a new tape that is not write-protected in the tape drive.</para>
</step><step id="bkuprestoretasks-step-69"><para>Make a level 0 backup of the newly
restored file system.</para><screen># <userinput>ufsdump 0ucf /dev/rmt/</userinput><replaceable>n</replaceable> <userinput>/dev/rdsk/</userinput><replaceable>device-name</replaceable></screen><para>A level 0 backup is performed. Always immediately do a full backup of
a newly created file system because the <command>ufsrestore</command> command
repositions the files and changes the inode allocation.</para>
</step><step id="bkuprestoretasks-step-70"><para>Mount the restored file system.</para><screen># <userinput>mount /dev/dsk/</userinput><replaceable>device-name mount-point</replaceable></screen><para>The restored file system is mounted and available for use.</para>
</step><step id="bkuprestoretasks-step-1"><para>Verify that the restored and mounted
file system is available.</para><screen># <userinput>ls</userinput> <replaceable>mount-point</replaceable></screen>
</step>
</procedure><example id="fncrr"><title>Restoring a Complete File System</title><para>The following example shows how to restore the <filename>/export/home</filename> file
system.</para><screen># <userinput>newfs /dev/rdsk/c0t0d0s7</userinput>
newfs: /dev/rdsk/c0t0d0s7 last mounted as /export/home
newfs: construct a new file system /dev/rdsk/c0t0d0s7: (y/n)? <userinput>y</userinput>
819314 sectors in 867 cylinders of 15 tracks, 63 sectors
        400.1MB in 55 cyl groups (16 c/g, 7.38MB/g, 3584 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
 32, 15216, 30400, 45584, 60768, 75952, 91136, 106320, 121504, 136688,
 681264, 696448, 711632, 725792, 740976, 756160, 771344, 786528, 801712,
 816896,
# <userinput>mount /dev/dsk/c0t0d0s7 /mnt</userinput>
# <userinput>cd /mnt</userinput>
# <userinput>ufsrestore rvf /dev/rmt/0</userinput>
Verify volume and initialize maps
Media block size is 126
Dump   date: Thu Jul 29 10:14:00 2004
Dumped from: the epoch
Level 0 dump of /export/home on starbug:/dev/dsk/c0t0d0s7
Label: none
Begin level 0 restore
Initialize symbol table.
Extract directories from tape
Calculate extraction list.
Warning: ./lost+found: File exists
Make node ./rimmer
Make node ./rimmer/wdir
Make node ./lister
Make node ./pmorph
Make node ./inquisitor
Make node ./kryten
Make node ./kryten/letters
Make node ./kryten/reports
Extract new leaves.
Check pointing the restore
extract file ./rimmer/words
extract file ./rimmer/words1
extract file ./rimmer/words2
extract file ./rimmer/words3
extract file ./rimmer/wdir/words
extract file ./rimmer/wdir/words1
extract file ./rimmer/wdir/words2
extract file ./rimmer/wdir/words3
.
.
.
Add links
Set directory mode, owner, and times.
Check the symbol table.
Check pointing the restore
# <userinput>rm restoresymtable</userinput>
# <userinput>cd /</userinput>
# <userinput>umount /mnt</userinput>
# <userinput>ufsdump 0ucf /dev/rmt/0 /export/home</userinput>
                    .
                    .
                    .
# <userinput>mount /dev/dsk/c0t0d0s7 /export/home</userinput>
# <userinput>ls /export/home</userinput></screen>
</example>
</task><task id="bkuprestoretasks-87945"><title>How to Restore the root (<filename>/</filename>)
and <filename>/usr</filename> File Systems</title><procedure><step id="bkuprestoretasks-step-9"><para>Become superuser or assume an equivalent
role.</para>
</step><step id="bkuprestoretasks-step-73"><para>Add a new system disk to the system
where the root (<filename>/</filename>) and <filename>/usr</filename> file
systems will be restored.</para><para>For a detailed description about adding
a system disk, refer to <olink targetptr="diskssadd-55658" remap="internal">How to Connect
a System Disk and Boot</olink> or <olink targetptr="disksxadd-12484" remap="internal">How to
Connect a System Disk</olink>.</para>
</step><step id="bkuprestoretasks-step-74"><para>Mount the new file system on a temporary
mount point.</para><screen># <userinput>mount /dev/dsk/</userinput><replaceable>device-name</replaceable> <userinput>/mnt</userinput></screen>
</step><step id="bkuprestoretasks-step-75"><para>Change to the <filename>/mnt</filename> directory.</para><screen># <userinput>cd /mnt</userinput></screen>
</step><step id="bkuprestoretasks-step-77"><para>(Optional) Write-protect the tapes
for safety.</para>
</step><step><para>Create the links for the tape device.</para><screen># <userinput>tapes</userinput></screen>
</step><step id="bkuprestoretasks-step-78"><para>Restore the root (<filename>/</filename>)
file system.</para><screen># <userinput>ufsrestore rvf /dev/rmt/</userinput><replaceable>n</replaceable></screen><para>The dump level 0 tape is restored.</para>
</step><step id="bkuprestoretasks-step-79"><para>Remove the tape and load the next
level tape in the drive.</para><para>Always restore tapes starting with dump
level 0 and continuing from the lowest to highest dump level.</para>
</step><step id="bkuprestoretasks-step-80"><para>Continue restoring as needed.</para><screen># <userinput>ufsrestore rvf /dev/rmt/</userinput><replaceable>n</replaceable></screen><para>The next level tape is restored.</para>
</step><step id="bkuprestoretasks-step-81"><para>Repeat <olink targetptr="bkuprestoretasks-step-79" remap="internal">Step&nbsp;8</olink> and <olink targetptr="bkuprestoretasks-step-80" remap="internal">Step&nbsp;9</olink> for each additional
tape.</para>
</step><step id="bkuprestoretasks-step-95"><para>Verify that the file system has
been restored.</para><screen># <userinput>ls</userinput></screen>
</step><step id="bkuprestoretasks-step-82"><para>Remove the <filename>restoresymtable</filename> file.</para><screen># <userinput>rm restoresymtable</userinput></screen><para>The <filename>restoresymtable</filename> file that is created and used
by the <command>ufsrestore</command> command to check-point the restore is
removed.</para>
</step><step id="bkuprestoretasks-step-83"><para>Change to the root (<filename>/</filename>)
directory.</para><screen># <userinput>cd /</userinput></screen>
</step><step id="bkuprestoretasks-step-84"><para>Unmount the newly created file system.</para><screen># <userinput>umount /mnt</userinput></screen>
</step><step id="bkuprestoretasks-step-85"><para>Check the new file system.</para><screen># <userinput>fsck /dev/rdsk/</userinput><replaceable>device-name</replaceable></screen><para>The restored file system is checked for consistency.</para>
</step><step id="bkuprestoretasks-step-96"><para>Create the boot blocks on the root
partition.</para><para>On a SPARC system:</para><screen># <userinput>installboot  /usr/platform/`uname-i`/lib/fs/ufs/bootblk</userinput> 
<userinput>/dev/rdsk/</userinput><replaceable>device-name</replaceable></screen><para>For more information, see the <olink targetdoc="refman1m" targetptr="installboot-1m" remap="external"><citerefentry><refentrytitle>installboot</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink> man page.</para><para>For
an example of using the <command>installboot</command> command on a SPARC
based system, see <olink targetptr="bkuprestoretasks-102" remap="internal">Example&nbsp;26&ndash;6</olink>. </para><para>On an x86 system:</para><screen># <userinput>/sbin/installgrub /boot/grub/stage1 /boot/grub/stage2</userinput> <replaceable>/dev/rdsk/cwtxdysz</replaceable></screen><para>For more information, see <olink targetdoc="refman1m" targetptr="installgrub-1m" remap="external"><citerefentry><refentrytitle>installgrub</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink>.</para><para>For
an example of using the <command>installgrub</command> command on an x86 based
system, see <olink targetptr="bkuprestoretasks-90" remap="internal">Example&nbsp;26&ndash;7</olink>.</para>
</step><step id="bkuprestoretasks-step-86"><para>Insert a new tape in the tape drive.</para>
</step><step id="bkuprestoretasks-step-87"><para>Back up the new file system.</para><screen># <userinput>ufsdump 0uf /dev/rmt/</userinput><replaceable>n</replaceable> <userinput>/dev/rdsk/</userinput><replaceable>device-name</replaceable></screen><para>A dump level 0 backup is performed. Always immediately do a full backup
of a newly created file system because the <command>ufsrestore</command> command
repositions the files and changes the inode allocation.</para>
</step><step id="bkuprestoretasks-step-88"><para>Repeat steps 5 through 16 for the <filename>/usr</filename> file system, if necessary.</para>
</step><step id="bkuprestoretasks-step-89"><para>Reboot the system.</para><screen># <userinput>init 6</userinput></screen><para>The system is rebooted.</para>
</step>
</procedure><example id="bkuprestoretasks-102" arch="sparc"><title>Restoring the root (<filename>/</filename>) File System</title><para>This example shows how to restore the root (<filename>/</filename>)
file system on a SPARC system. This example assumes that the system is booted
from a local CD or from the network.</para><screen># <userinput>mount /dev/dsk/c0t3d0s0 /mnt</userinput>
# <userinput>cd /mnt</userinput>
# <userinput>tapes</userinput>
# <userinput>ufsrestore rvf /dev/rmt/0</userinput>
# <userinput>ls</userinput>
# <userinput>rm restoresymtable</userinput>
# <userinput>cd /</userinput>
# <userinput>umount /mnt</userinput>
# <userinput>fsck /dev/rdsk/c0t3d0s0</userinput>
# <userinput>installboot /usr/platform/sun4u/lib/fs/ufs/bootblk</userinput>
<userinput>/dev/rdsk/c0t3d0s0</userinput>
# <userinput>ufsdump 0uf /dev/rmt/0 /dev/rdsk/c0t3d0s0</userinput>
# <userinput>init 6</userinput></screen>
</example><example id="bkuprestoretasks-90" arch="x86"><title>Restoring the root (<filename>/</filename>) File System</title><para>This example shows how to restore the root (<filename>/</filename>)
file system on an x86 system. This example assumes that the system is booted
from a GRUB failsafe boot session, local CD, or from the network.</para><screen># <userinput>mount /dev/dsk/c0t3d0s0 /mnt</userinput>
# <userinput>cd /mnt</userinput>
# <userinput>tapes</userinput>
# <userinput>ufsrestore rvf /dev/rmt/0</userinput>
# <userinput>ls</userinput>
# <userinput>rm restoresymtable</userinput>
# <userinput>cd /</userinput>
# <userinput>umount /mnt</userinput>
# <userinput>fsck /dev/rdsk/c0t3d0s0</userinput>
# <userinput>/sbin/installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c0t3d0s0</userinput>
stage1 written to partition 0 sector 0 (abs 2016)
stage2 written to to partition 0, 227 sectors starting 50 (abs 2066)
# <userinput>ufsdump 0uf /dev/rmt/0 /dev/rdsk/c0t3d0s0</userinput>
# <userinput>init 6</userinput></screen>
</example>
</task>
</sect1>
</chapter>