<chapter id="bkuptasks2-64128"><title>Backing
Up Files and File Systems (Tasks)</title><highlights><para>This chapter describes the procedures for backing up file systems by
using the <command>ufsdump</command> command.</para><para>For information on these procedures, see <olink targetptr="bkuptasks2-3" remap="internal">Backing
Up Files and File System (Task Map)</olink>.</para><para>For overview information about performing backups, see <olink targetptr="bkupconcepts-57422" remap="internal">Chapter&nbsp;23, Backing Up and Restoring File Systems (Overview)</olink>.</para><para>For information about backing up individual files to diskettes, see <olink targetptr="bkupsavefiles-17924" remap="internal">Chapter&nbsp;28, Copying UFS Files and File Systems (Tasks)</olink>.</para><para>For additional information on the <command>ufsdump</command> command,
see <olink targetptr="bkupref-12756" remap="internal">Chapter&nbsp;27, UFS Backup and Restore Commands (Reference)</olink>.</para>
</highlights><sect1 id="bkuptasks2-3"><title>Backing Up Files and File System (Task Map)</title><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>1. Prepare for file system backups.</para>
</entry><entry><para>Identify the file systems, the type of backup, and the tape device to
be used for the backups.</para>
</entry><entry><para><olink targetptr="bkuptasks2-1" remap="internal">Preparing for File System Backups</olink></para>
</entry>
</row><row><entry><para>2. Determine the number of tapes needed to back up a file system.</para>
</entry><entry><para>Determine the number of tapes that are needed for a full backup of a
file system.</para>
</entry><entry><para><olink targetptr="bkuptasks2-80196" remap="internal">How to Determine the Number of Tapes
Needed for a Full Backup</olink></para>
</entry>
</row><row><entry><para>3. Back up file systems.</para>
</entry><entry><para>Perform a full backup of file systems to get baseline copies of all
files.</para><para>Perform an incremental backup of file systems based on whether keeping
copies of files that have changed on a daily basis is important at your site.</para>
</entry><entry><para><olink targetptr="bkuptasks2-34493" remap="internal">How to Back Up a File System to
Tape</olink></para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</sect1><sect1 id="bkuptasks2-1"><title>Preparing for File System Backups</title><para>The preparation for backing up file systems begins with planning, which
is described in <olink targetptr="bkupconcepts-57422" remap="internal">Chapter&nbsp;23, Backing Up and Restoring File Systems (Overview)</olink> and includes choosing the
following: </para><itemizedlist><listitem><para>The file systems to back up</para>
</listitem><listitem><para>The type of backup (full or incremental) to perform</para>
</listitem><listitem><para>A backup schedule</para>
</listitem><listitem><para>A tape drive</para>
</listitem>
</itemizedlist><para>For more information, see <olink targetptr="bkupconcepts-57422" remap="internal">Chapter&nbsp;23, Backing Up and Restoring File Systems (Overview)</olink>.</para><para>This section describes two other tasks you might need to perform before
you back up file systems:</para><itemizedlist><listitem><para>Finding the names of file systems to back up</para>
</listitem><listitem><para>Determining the number of tapes that are needed for a full
backup</para>
</listitem>
</itemizedlist><task id="bkuptasks2-78540"><title>How to Find File System Names</title><procedure><step id="bkuptasks2-step-3"><para>Display the contents of the <filename>/etc/vfstab</filename> file.</para><screen>$ <userinput>more /etc/vfstab</userinput></screen>
</step><step id="bkuptasks2-step-4"><para>Look in the <literal>mount point</literal> column
for the name of the file system.</para>
</step><step id="bkuptasks2-step-5"><para>Use the directory name listed in the <literal>mount point</literal> column when you back up the file system.</para>
</step>
</procedure><example id="fncrk"><title>Finding File System Names</title><para>In this example, the file systems to be backed up are root (<filename>/</filename>), <filename>/usr</filename>, <filename>/datab</filename>, and <filename>/export/home</filename>.</para><screen>$ <userinput>more /etc/vfstab</userinput>
#device           device               mount        FS    fsck mount   mount
#to mount         to fsck              point        type  pass at boot options
/devices           -                   /devices     devfs   -     no      -
.
.
.
/proc              -                    /proc       proc    -     no      -
/dev/dsk/c0t0d0s1  -                    -           swap    -     no      -
/dev/dsk/c0t0d0s0 /dev/rdsk/c0t0d0s0   /            ufs     1     no      -
/dev/dsk/c0t0d0s6 /dev/rdsk/c0t0d0s6   /usr         ufs     1     no      -
/dev/dsk/c0t0d0s5 /dev/rdsk/c0t0d0s5   /datab       ufs     2     yes     -
/dev/dsk/c0t0d0s7 /dev/rdsk/c0t0d0s7   /export/home ufs     2     yes     -
swap              -                    /tmp         tmpfs   -     yes     -</screen>
</example>
</task><task id="bkuptasks2-80196"><title>How to Determine the Number of Tapes Needed
for a Full Backup</title><procedure><step id="bkuptasks2-step-8"><para>Become superuser or assume an equivalent
role.</para>
</step><step id="bkuptasks2-step-9"><para>Estimate the size of the backup in bytes.</para><screen># <userinput>ufsdump</userinput> [<replaceable>0</replaceable>]S <replaceable>file-system</replaceable></screen><para>Use the <literal>S</literal> option to display the estimated number
of bytes that are needed to do the backup if this is the first backup of the
file system.</para><para>Use the <literal>0S</literal> option
to display the estimated number of bytes that are needed to do the backup
if this is not the first backup of the file system.</para>
</step><step id="bkuptasks2-step-10"><para>Divide the estimated size by the capacity
of the tape to determine how many tapes you need.</para><para>For a list of
tape capacities, see <olink targetptr="bkupconcepts-32470" remap="internal">Table&nbsp;23&ndash;5</olink>.</para>
</step>
</procedure><example id="fncrn"><title>Determining the Number of Tapes</title><para>In this example, the file system of 489,472 bytes easily fits on a 150-Mbyte
tape.</para><screen># <userinput>ufsdump S /export/home</userinput>
489472</screen>
</example>
</task>
</sect1><sect1 id="bkuptasks2-21046"><title>Backing Up a File System</title><para>The following are general guidelines for performing backups:</para><itemizedlist><listitem><para>Use single-user mode or unmount the file system, unless you
are creating a snapshot of a file system. For information about UFS snapshots,
see <olink targetptr="bkupsnapshot-2" remap="internal">Chapter&nbsp;25, Using UFS Snapshots (Tasks)</olink>.</para>
</listitem><listitem><para>Be aware that backing up file systems when directory-level
operations (such as creating, removing, and renaming files) and file-level
activity are occurring simultaneously means that some data will not be included
in the backup.</para>
</listitem><listitem><para>You can run the <command>ufsdump</command> command from a single
system and remotely back up groups of systems across the network through remote
shell or remote login. In addition, you can direct the output to the system
on which the tape device is located. Typically, the tape device is located
on the system from which you run the <command>ufsdump</command> command, but
it does not have to be.</para><para>Another way to back up files to a remote
device is to pipe the output from the <command>ufsdump</command> command to
the <command>dd</command> command. For information about using the <command>dd</command> command,
see <olink targetptr="bkupsavefiles-17924" remap="internal">Chapter&nbsp;28, Copying UFS Files and File Systems (Tasks)</olink>.</para>
</listitem><listitem><para>If you are doing remote backups across the network, the system
with the tape device must have entries in its <filename>/.rhosts</filename> file
for each client that will be using the device. Also, the system that initiates
the backup must be included in the <filename>/.rhosts</filename> file on each
system that it will back up.</para>
</listitem>
</itemizedlist><task id="bkuptasks2-34493"><title>How to Back Up a File System to Tape</title><tasksummary><para>The following are general steps for backing up file systems by using
the <command>ufsdump</command> command. The examples show specific uses of
options and arguments.</para>
</tasksummary><procedure><step id="bkuptasks2-step-11"><para>Become superuser or assume an equivalent
role.</para>
</step><step id="bkuptasks2-step-15"><para>Bring the system to run level S (single-user
mode).</para><para>For example:</para><screen># <userinput>shutdown -g30 -y</userinput></screen>
</step><step id="bkuptasks2-step-16"><para>(Optional) Check the file system for consistency.</para><para>For example:</para><screen># <userinput>fsck -m /dev/rdsk/c0t0d0s7</userinput></screen><para>The <command>fsck -m</command> command checks for the consistency of
file systems. For example, power failures can leave files in an inconsistent
state. For more information on the <command>fsck</command> command, see <olink targetptr="fstroublefsck-61446" remap="internal">Chapter&nbsp;21, Checking UFS File System Consistency (Tasks)</olink>.</para>
</step><step id="bkuptasks2-step-17"><para>If you need to back up file systems to
a remote tape drive, follow these steps:</para><substeps><step id="bkuptasks2-step-25"><para>On the system to which the tape drive
is attached (the tape server), add the following entry to its <filename>/.rhosts</filename> file:</para><screen><replaceable>host</replaceable> root</screen><para>The <replaceable>host</replaceable> entry specifies the name of the
system on which you will run the <command>ufsdump</command> command to perform
the backup.</para>
</step><step id="bkuptasks2-step-2"><para>On the tape server, verify that the host
added to the <filename>/.rhosts</filename> file is accessible through the
name service.</para>
</step>
</substeps>
</step><step id="bkuptasks2-step-18"><para>Identify the device name of the tape drive.</para><para>The default tape drive is the <filename>/dev/rmt/0</filename> device.</para>
</step><step id="bkuptasks2-step-19"><para>Insert a tape that is write-enabled into
the tape drive.</para>
</step><step id="bkuptasks2-step-20"><para>Back up file systems.</para><screen># <userinput>ufsdump</userinput> <replaceable>options arguments filenames</replaceable></screen><para>You can back up file systems or directories, or files within file systems.
For information on backing up individual files, see <olink targetdoc="refman1" targetptr="tar-1" remap="external"><citerefentry><refentrytitle>tar</refentrytitle><manvolnum>1</manvolnum></citerefentry></olink> or <olink targetdoc="refman1" targetptr="cpio-1" remap="external"><citerefentry><refentrytitle>cpio</refentrytitle><manvolnum>1</manvolnum></citerefentry></olink>.</para><para>The following examples show how to use the most common <command>ufsdump</command> options and arguments:</para><itemizedlist><listitem><para><olink targetptr="bkuptasks2-26447" remap="internal">Example&nbsp;24&ndash;3</olink></para>
</listitem><listitem><para><olink targetptr="bkuptasks2-42264" remap="internal">Example&nbsp;24&ndash;4</olink></para>
</listitem><listitem><para><olink targetptr="bkuptasks2-19106" remap="internal">Example&nbsp;24&ndash;5</olink></para>
</listitem><listitem><para><olink targetptr="bkuptasks2-13035" remap="internal">Example&nbsp;24&ndash;6</olink></para>
</listitem>
</itemizedlist><para>For other <command>ufsdump</command> options and arguments, see <olink targetptr="bkupref-12756" remap="internal">Chapter&nbsp;27, UFS Backup and Restore Commands (Reference)</olink>.</para>
</step><step id="bkuptasks2-step-21"><para>If prompted, remove the tape and insert
the next tape volume.</para>
</step><step id="bkuptasks2-step-22"><para>Label each tape with the volume number,
dump level, date, system name, disk slice, and file system. </para>
</step><step id="bkuptasks2-step-23"><para>Bring the system back to run level 3 by
pressing Control-D.</para>
</step><step id="bkuptasks2-step-24"><para>Verify that the backup was successful.</para><screen># <userinput>ufsrestore tf</userinput> <replaceable>device-name</replaceable></screen>
</step>
</procedure><example id="bkuptasks2-26447"><title>Performing a Full Backup of root (<filename>/</filename>)</title><para>The following example shows how to do a full backup of the root
(<filename>/</filename>) file system. The system in this example is brought
to single-user mode before the backup. The following <command>ufsdump</command> options
are included:</para><itemizedlist><listitem><para><literal>0</literal> specifies a <literal>0</literal> level
dump (or a full backup).</para>
</listitem><listitem><para><literal>u</literal> specifies that the <filename>/etc/dumpdates</filename> file
is updated with the date of this backup.</para>
</listitem><listitem><para><literal>c</literal> identifies a cartridge tape device.</para>
</listitem><listitem><para><literal>f /dev/rmt/0</literal> identifies the tape device.</para>
</listitem><listitem><para><literal>/</literal> is the file system being backed up.</para>
</listitem>
</itemizedlist><para>For example:</para><screen># <userinput>init 0</userinput>
ok <userinput>boot -s</userinput>
# <userinput>ufsdump 0ucf /dev/rmt/0 /</userinput>
  DUMP: Date of this level 0 dump: Wed Jul 28 16:13:52 2004
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0t0d0s0 (starbug:/) to /dev/rmt/0.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Writing 63 Kilobyte records
  DUMP: Estimated 363468 blocks (177.47MB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: Tape rewinding
  DUMP: 369934 blocks (180.63MB) on 1 volume at 432 KB/sec
  DUMP: DUMP IS DONE
  DUMP: Level 0 dump on Wed Jul 28 16:13:52 2004
  # <userinput>ufsrestore tf /dev/rmt/0</userinput>
         2      .
         3      ./lost+found
         4      ./usr
         5      ./export
         6      ./export/home
         7      ./var
         8      ./var/sadm
         9      ./var/sadm/install
        10      ./var/sadm/install/admin
       823      ./var/sadm/install/admin/default
        11      ./var/sadm/install/logs
       697      ./var/sadm/install/logs/SUNWmpatchmgr
       905      ./var/sadm/install/logs/Additional_Software_install...
       906      ./var/sadm/install/logs/Additional_Software_install...
        13      ./var/sadm/install/.lockfile
        14      ./var/sadm/install/install.db
       824      ./var/sadm/install/special_contents
       838      ./var/sadm/install/contents
                .
                .
                .
  # (<emphasis>Press Control-D to bring system to run level 3</emphasis>)</screen>
</example><example id="bkuptasks2-42264"><title>Performing an Incremental Backup of root (<filename>/</filename>)</title><para>The following example shows how to do an incremental backup of
the root (<filename>/</filename>) file system in single-user mode. The following <command>ufsdump</command> options are included:</para><itemizedlist><listitem><para><literal>9</literal> specifies a <literal>9</literal> level
dump (or an incremental backup).</para>
</listitem><listitem><para><literal>u</literal> specifies that the <filename>/etc/dumpdates</filename> file
is updated with the date of this backup.</para>
</listitem><listitem><para><literal>c</literal> identifies a cartridge tape device.</para>
</listitem><listitem><para><literal>f /dev/rmt/0</literal> identifies the tape device.</para>
</listitem><listitem><para><literal>/</literal> is the file system being backed up.</para>
</listitem>
</itemizedlist><screen># <userinput>init 0</userinput>
ok <userinput>boot -s</userinput>
# <userinput>ufsdump 9ucf /dev/rmt/0 /</userinput>
 DUMP: Date of this level 9 dump: Wed Jul 28 14:26:50 2004
 DUMP: Date of last level 0 dump: Wed Jul 28 11:15:41 2004
 DUMP: Dumping /dev/rdsk/c0t0d0s0 (starbug:/) to /dev/rmt/0.
 DUMP: Mapping (Pass I) [regular files]
 DUMP: Mapping (Pass II) [directories]
 DUMP: Writing 63 Kilobyte records
 DUMP: Estimated 335844 blocks (163.99MB).
 DUMP: Dumping (Pass III) [directories]
 DUMP: Dumping (Pass IV) [regular files]
 DUMP: 335410 blocks (163.77MB) on 1 volume at 893 KB/sec
 DUMP: DUMP IS DONE
 DUMP: Level 9 dump on Wed Jul 28 14:30:50 2004
 # <userinput>ufsrestore tf /dev/rmt/0</userinput>
         2      .
         3      ./lost+found
      5696      ./usr
     11392      ./var
     17088      ./export
     22784      ./export/home
     28480      ./opt
      5697      ./etc
     11393      ./etc/default
     11394      ./etc/default/sys-suspend
     11429      ./etc/default/cron
     11430      ./etc/default/devfsadm
     11431      ./etc/default/dhcpagent
     11432      ./etc/default/fs
     11433      ./etc/default/inetinit
     11434      ./etc/default/kbd
     11435      ./etc/default/nfslogd
     11436      ./etc/default/passwd
     11437      ./etc/default/tar
                .
                .
                .</screen>
</example><example id="bkuptasks2-19106"><title>Performing a Full Backup of a Home Directory</title><para>The following example shows how to do a full backup of the <filename>/export/home/kryten</filename> home directory. The following <command>ufsdump</command> options
are included:</para><itemizedlist><listitem><para><literal>0</literal> specifies that this is a <literal>0</literal> level
dump (or a full backup).</para>
</listitem><listitem><para><literal>u</literal> specifies that the <filename>/etc/dumpdates</filename> file
is updated with the date of this backup.</para>
</listitem><listitem><para><literal>c</literal> identifies a cartridge tape device.</para>
</listitem><listitem><para><literal>f /dev/rmt/0</literal> identifies the tape device.</para>
</listitem><listitem><para><literal>/export/home/kryten</literal> is the directory being
backed up.</para>
</listitem>
</itemizedlist><screen># <userinput>ufsdump 0ucf /dev/rmt/0 /export/home/kryten</userinput>
  DUMP: Date of this level 0 dump: Wed Jul 28 15:02:48 2004
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0t0d0s7 (starbug:/export/home) to /dev/rmt/0.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Writing 63 Kilobyte records
  DUMP: Estimated 2412 blocks (1.18MB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: 2392 blocks (1.17MB) on 1 volume at 4241 KB/sec
  DUMP: DUMP IS DONE
# <userinput>ufsrestore tf /dev/rmt/0</userinput>
       232      ./kryten
       233      ./kryten/filea
       234      ./kryten/fileb
       235      ./kryten/filec
       236      ./kryten/letters
       237      ./kryten/letters/letter1
       238      ./kryten/letters/letter2
       239      ./kryten/letters/letter3
       240      ./kryten/reports
       241      ./kryten/reports/reportA
       242      ./kryten/reports/reportB
       243      ./kryten/reports/reportC
#</screen>
</example><example id="bkuptasks2-13035"><title>Performing a Full Backup to a Remote System ( Data to  System)</title><para>The following example shows how to do a full backup of a local <filename>/export/home</filename> file system on a  system (<literal>mars</literal>) to a tape device on a remote  system (<literal>earth</literal>) in single-user mode. The following <command>ufsdump</command> options are included:</para><itemizedlist><listitem><para><literal>0</literal> specifies a <literal>0</literal> level
dump (or a full backup).</para>
</listitem><listitem><para><literal>u</literal> specifies that the <filename>/etc/dumpdates</filename> file
is updated with the date of this backup.</para>
</listitem><listitem><para><literal>c</literal> identifies a cartridge tape device.</para>
</listitem><listitem><para><literal>f earth:/dev/rmt/0</literal> identifies the remote
system name and tape device.</para>
</listitem><listitem><para><literal>/export/home</literal> is the file system being backed
up.</para>
</listitem>
</itemizedlist><screen># <userinput>ufsdump 0ucf earth:/dev/rmt/0 /export/home</userinput>
  DUMP: Date of this level 0 dump: Wed Jul 28 15:52:59 2004
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0t0d0s7 (mars:/export/home) to earth:/dev/rmt/0.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Writing 63 Kilobyte records
  DUMP: Estimated 8282 blocks (4.04MB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: Tape rewinding
  DUMP: 8188 blocks (4.00MB) on 1 volume at 67 KB/sec
  DUMP: DUMP IS DONE
  DUMP: Level 0 dump on Wed Jul 28 15:52:59 2004
# <userinput>ufsrestore tf earth:/dev/rmt/0</userinput>
         2      .
         3      ./lost+found
         4      ./kryten
         5      ./kryten/filea
         6      ./kryten/fileb
         7      ./kryten/filec
         8      ./kryten/letters
         9      ./kryten/letters/letter1
        10      ./kryten/letters/letter2
        11      ./kryten/letters/letter3
        12      ./kryten/reports
.
.
.
 #</screen>
</example>
</task>
</sect1>
</chapter>