<chapter id="bkupsnapshot-2"><title>Using
UFS Snapshots (Tasks)</title><highlights><para>This chapter describes how to create and back up UFS snapshots.</para><para>For information on the procedures associated with creating UFS snapshots,
see <olink targetptr="bkupsnapshot-1" remap="internal">Using UFS Snapshots (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>
</highlights><sect1 id="bkupsnapshot-1"><title>Using UFS Snapshots (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. Create a UFS snapshot.</para>
</entry><entry><para>Create a read-only copy of a file system by using the <command>fssnap</command> command.</para>
</entry><entry><para><olink targetptr="bkupsnapshot-6" remap="internal">How to Create a UFS Snapshot</olink></para>
</entry>
</row><row><entry><para>2. Display UFS snapshot information.</para>
</entry><entry><para>Identify UFS snapshot information such as the raw snapshot device.</para>
</entry><entry><para><olink targetptr="bkupsnapshot-7" remap="internal">How to Display UFS Snapshot Information</olink></para>
</entry>
</row><row><entry><para>3. (Optional) Delete a UFS snapshot.</para>
</entry><entry><para> Delete a snapshot that is already backed up or no longer needed.</para>
</entry><entry><para><olink targetptr="bkupsnapshot-8" remap="internal">How to Delete a UFS Snapshot</olink></para>
</entry>
</row><row><entry><para>4. (Optional) Back up a UFS snapshot.</para>
</entry><entry><para>Choose one of the following backup methods:</para>
</entry><entry><para></para>
</entry>
</row><row><entry rowsep="0"><para></para>
</entry><entry rowsep="0"><para>Create a full backup of a UFS snapshot by using the <command>ufsdump</command> command.</para>
</entry><entry rowsep="0"><para><olink targetptr="bkupsnapshot-10" remap="internal">How to Create a Full Backup of a
UFS Snapshot (ufsdump)</olink></para>
</entry>
</row><row><entry rowsep="0"><para></para>
</entry><entry rowsep="0"><para>Create an incremental backup of a UFS snapshot by using the <command>ufsdump</command> command.</para><para></para>
</entry><entry rowsep="0"><para><olink targetptr="bkupsnapshot-16" remap="internal">How to Create an Incremental Backup
of a UFS Snapshot (ufsdump)</olink></para>
</entry>
</row><row><entry rowsep="1"><para></para>
</entry><entry rowsep="1"><para>Back up a UFS snapshot by using the <command>tar</command> command.</para>
</entry><entry rowsep="1"><para><olink targetptr="bkupsnapshot-12" remap="internal">How to Back Up a UFS Snapshot (tar)</olink></para>
</entry>
</row><row><entry><para>5. (Optional) Restore data from a UFS snapshot.</para>
</entry><entry><para>Restore the UFS snapshot the same way as you would restore data by using
the <command>ufsrestore</command> command.</para>
</entry><entry><para><olink targetptr="bkuprestoretasks-65439" remap="internal">How to Restore a Complete
File System</olink></para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</sect1><sect1 id="bkupsnapshot-11"><title>UFS Snapshots Overview</title><para>You can use the <command>fssnap</command> command to back up file systems
while the file system is mounted. This command to creates a read-only snapshot
of a file system. A <emphasis>snapshot</emphasis> is a file system's temporary
image that is intended for backup operations.</para><para>When the <command>fssnap</command> command is run, it creates a virtual
device and a backing-store file. You can back up the <emphasis>virtual device</emphasis>,
which looks and acts like a real device, with any of the existing Solaris
backup commands. The <emphasis>backing-store file</emphasis> is a bitmap file
that contains copies of pre snapshot data that has been modified since the
snapshot was taken.</para><para>Keep the following key points in mind when specifying backing-store
files:</para><itemizedlist><listitem><para>The destination path of the backing store files must have
enough free space to hold the file system data. The size of the backing store
files vary with the amount of activity on the file system.</para>
</listitem><listitem><para>The backing store file location must be different from the
file system that is being captured in a snapshot.</para>
</listitem><listitem><para>The backing-store files can reside on any type of  file system,
including another UFS file system or an NFS file system.</para>
</listitem><listitem><para>Multiple backing-store files are created when you create a
snapshot of a UFS file system that is larger than 512 Gbytes.</para>
</listitem><listitem><para>Backing-store files are sparse files. The logical size of
a sparse file, as reported by the <command>ls</command> command, is not the
same as the amount of space that has been allocated to the sparse file, as
reported by the <command>du</command> command.</para>
</listitem>
</itemizedlist><para>For more information about creating snapshots for a UFS file system
larger than 512 Gbytes, see <olink targetptr="fapul" remap="internal">Creating a Multiterabyte
UFS Snapshot</olink>.</para><sect2 id="bkupsnapshot-3"><title>Why Use UFS Snapshots?</title><para>The UFS snapshots feature provides additional availability and convenience
for backing up a file system because the file system remains mounted and the
system remains in multiuser mode during backups. Then, you can use the <command>tar</command> or <command>cpio</command> commands to back up a UFS snapshot to
tape for more permanent storage. If you use the <command>ufsdump</command> command
to perform backups, the system should be in single-user mode to keep the file
system inactive when you perform backups.</para><para>The <command>fssnap</command> command gives administrators of
non enterprise-level systems the power of enterprise-level tools, such as
Sun <trademark>StorEdge</trademark> Instant Image, without the large storage
demands.</para><para>The UFS snapshots feature is similar to the Instant Image product. Although
UFS snapshots can make copies of large file systems, Instant Image is better
suited for enterprise-level systems. UFS snapshots is better suited for smaller
systems. Instant Image allocates space equal to the size of the entire file
system that is being captured. However, the backing-store file that is created
by UFS snapshots occupies only as much disk space as needed.</para><para>This table describes specific differences between UFS snapshots and
Instant Image.</para><informaltable frame="topbot"><tgroup cols="2" colsep="0" rowsep="0"><colspec colname="colspec0" colwidth="198*"/><colspec colname="colspec1" colwidth="198*"/><thead><row rowsep="1"><entry><para>UFS Snapshots</para>
</entry><entry><para>Sun StorEdge Instant Image</para>
</entry>
</row>
</thead><tbody><row><entry><para>Size of the backing-store file depends on how much data has changed
since the snapshot was taken</para>
</entry><entry><para>Size of the backing-store file equals the size of the entire file system
being copied</para>
</entry>
</row><row><entry><para>Does not persist across system reboots</para>
</entry><entry><para>Persists across system reboots</para>
</entry>
</row><row><entry><para>Works on UFS file systems</para>
</entry><entry><para>Cannot be used with root (<filename>/</filename>) or <filename>/usr</filename> file
systems</para>
</entry>
</row><row><entry><para>Available starting with the Solaris 8 1/01 release</para>
</entry><entry><para>Part of Sun StorEdge products</para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</sect2><sect2 id="bkupsnapshot-20"><title>UFS Snapshots Performance Issues</title><para>When the UFS snapshot is first created, users of the file system might
notice a slight pause. The length of the pause increases with the size of
the file system to be captured. While the snapshot is active, users of the
file system might notice a slight performance impact when the file system
is written to. However, they see no impact when the file system is read.</para>
</sect2>
</sect1><sect1 id="bkupsnapshot-5"><title>Creating and Deleting UFS Snapshots</title><para>When you use the <command>fssnap</command> command to create a UFS snapshot,
observe how much disk space the backing-store file consumes. The backing-store
file initially uses no space, and then it grows quickly, especially on heavily
used systems. Make sure that the backing-store file has enough space to expand.
Or, limit its size with the <option>o maxsize=n [k,m,g]</option> option, where <replaceable>n</replaceable> [<command>k,m,g</command>] is the maximum size of the backing-store
file.</para><caution><para>If the backing-store file runs out of space, the snapshot might
delete itself, which causes the backup to fail. Check the <filename>/var/adm/messages</filename> file for possible snapshot errors.</para>
</caution><para>You can also specify a directory for the backing-store path, which means
a backing store file is created in the directory specified. For example, if <filename>/var/tmp</filename> is specified for the backing-store path, the following
backing-store file is created.</para><screen>/var/tmp/snapshot0</screen><para>If you created one large root (<filename>/</filename>) file system instead
of creating separate file systems for <filename>/export/home</filename>, <filename>/usr</filename>, and so on, you will be unable to create a snapshot of those
separate file systems. For example, this system does not have a separate file
system for <filename>/usr</filename> as indicated under the <literal>Mounted
on</literal> column:</para><screen># <userinput>df -k /usr</userinput>
Filesystem            kbytes    used   avail capacity  Mounted on
/dev/dsk/c0t0d0s0    3618177 2190002 1391994    62%    /</screen><para>If you attempt to create a snapshot for the <filename>/usr</filename> file
system, you will see a message similar to the following:</para><screen># <userinput>fssnap -F ufs -o bs=/snaps/usr.back.file /usr</userinput>
snapshot error: Invalid backing file path</screen><para>This message indicates that you cannot have the backing store file on
the same file system as the file system being snapped, which is the case for
the <filename>/usr</filename> file system, in this example.</para><para>For more information, see the <olink targetdoc="refman1m" targetptr="fssnap-ufs-1m" remap="external"><citerefentry><refentrytitle>fssnap_ufs</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink> man page.</para><sect2 id="fapul"><title>Creating a Multiterabyte UFS Snapshot</title><para>Creating a multiterabyte UFS snapshot is identical to creating a snapshot
for a smaller UFS file system. The only difference is that multiple backing
store files are created for each 512 Gbytes of file system space.</para><para>Keep the following key points in mind when creating a snapshot for a
file system that is larger than 512 Gbytes:</para><itemizedlist><listitem><para>Multiple backing store files are created.</para><itemizedlist><listitem><para>If you specify a backing store file name when the snapshot
is created, then the subsequent backing store file names will be interated
based on the file name that you specify. The subsequent backing-store files
will have the same name, but with the suffixes .2, .3, and so on.</para>
</listitem><listitem><para>If you only specify a backing store file destination (or directory)
and not a backing store file name, then multiple backing store file names
will be created and iterated with the suffixes .2, .3, and so on.</para>
</listitem>
</itemizedlist>
</listitem><listitem><para>The <command>fssnap</command> <option>i</option> command only
reports the first backing store file name even if multiple backing store files
have been created. However, the reported backing-store length is the combined
sizes of all the backing store files for the snapshot.</para><note><para>Backing-store files are sparse files. The logical size of a sparse
file, as reported by the <command>ls</command> command, is not the same as
the amount of space that has been allocated to the sparse file, as reported
by the <command>du</command> command.</para>
</note>
</listitem><listitem><para>After you have backed up the snapshot or you would just like
to remove the snapshot, you will have to remove the backing store files manually
if you did not use the <literal>unlink</literal> option when the snapshot
was created.</para>
</listitem>
</itemizedlist><para>For an example of creating a snapshot for a file system that is larger
than 512 Gbytes, see <olink targetptr="fpypp" remap="internal">Example&nbsp;25&ndash;2</olink>.</para><para>For more information, see <olink targetdoc="refman1m" targetptr="fssnap-ufs-1m" remap="external"><citerefentry><refentrytitle>fssnap_ufs</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink>.</para>
</sect2><task id="bkupsnapshot-6"><title>How to Create a UFS Snapshot</title><procedure><step id="filesystem-step-4"><para>Become superuser or assume an equivalent
role.</para>
</step><step id="bkupsnapshot-step-29"><para>Make sure that the file system has enough
disk space for the backing-store file.</para><screen># <userinput>df -k</userinput> </screen>
</step><step id="bkupsnapshot-step-6"><para>Make sure that a backing-store file of the same name and location
does not already exist.</para><screen># <userinput>ls</userinput> <replaceable>/backing-store-file</replaceable></screen>
</step><step id="bkupsnapshot-step-7"><para>Create the UFS snapshot.</para><screen># <userinput>fssnap -F ufs -o bs=</userinput><replaceable>/backing-store-file</replaceable> <replaceable>/file-system</replaceable></screen><note><para>The backing-store file must reside on a different file system
than the file system that is being captured using UFS snapshots.</para>
</note>
</step><step id="bkupsnapshot-step-10"><para>Verify that the snapshot has been created.</para><screen># <userinput>/usr/lib/fs/ufs/fssnap -i</userinput> <replaceable>/file-system</replaceable></screen>
</step>
</procedure><example id="fncpv"><title>Creating a UFS Snapshot</title><para>The following example shows how to create a snapshot of the <filename>/usr</filename> file system. The backing-store file is <filename>/scratch/usr.back.file</filename>. The virtual device is <filename>/dev/fssnap/1</filename>.</para><screen># <userinput>fssnap -F ufs -o bs=/scratch/usr.back.file /usr</userinput>
/dev/fssnap/1</screen><para>The following example shows how to limit the backing-store file to 500
Mbytes.</para><screen># <userinput>fssnap -F ufs -o maxsize=500m,bs=/scratch/usr.back.file /usr</userinput> 
/dev/fssnap/1</screen>
</example><example id="fpypp"><title>Creating a Multiterabyte UFS Snapshot</title><para>The following example shows how to create a snapshot of a 1.6 Tbyte
UFS file system.</para><screen># <userinput>fssnap -F ufs -o bs=/var/tmp /data2</userinput>
/dev/fssnap/0
# <userinput>/usr/lib/fs/ufs/fssnap -i</userinput>
Snapshot number               : 0
Block Device                  : /dev/fssnap/0
Raw Device                    : /dev/rfssnap/0
Mount point                   : /data2
Device state                  : idle
Backing store path            : /var/tmp/snapshot0
Backing store size            : 0 KB
Maximum backing store size    : Unlimited
Snapshot create time          : Fri Sep 10 13:13:02 2004
Copy-on-write granularity     : 32 KB
# <userinput>ls /var/tmp</userinput>
snapshot0    snapshot0.2  snapshot0.3  snapshot0.4</screen>
</example>
</task><task id="bkupsnapshot-7"><title>How to Display UFS Snapshot Information</title><tasksummary><para>You can display the current snapshots on the system by using the <command>fssnap</command> <option>i</option> option. If you specify a file system, you see
detailed information about that file system snapshot. If you don't specify
a file system, you see information about all of the current UFS snapshots
and their corresponding virtual devices.</para><note><para>Use the UFS file system-specific <command>fssnap</command> command
to view the extended snapshot information as shown in the following examples.</para>
</note>
</tasksummary><procedure><step id="filesystem-step-5"><para>Become superuser or assume an equivalent
role.</para>
</step><step id="bkupsnapshot-step-12"><para>List all current snapshots.</para><para>For
example:</para><screen># <userinput>/usr/lib/fs/ufs/fssnap -i</userinput>
Snapshot number               : 0
Block Device                  : /dev/fssnap/0
Raw Device                    : /dev/rfssnap/0
Mount point                   : /export/home
Device state                  : idle
Backing store path            : /var/tmp/home.snap0
Backing store size            : 0 KB
Maximum backing store size    : Unlimited
Snapshot create time          : Thu Jul 01 14:50:38 2004
Copy-on-write granularity     : 32 KB</screen>
</step><step><para>Display detailed information about a specific snapshot.</para><para>For
example:</para><screen># <userinput>/usr/lib/fs/ufs/fssnap -i /export</userinput>
Snapshot number               : 1
Block Device                  : /dev/fssnap/1
Raw Device                    : /dev/rfssnap/1
Mount point                   : /export
Device state                  : idle
Backing store path            : /var/tmp/export.snap0
Backing store size            : 0 KB
Maximum backing store size    : Unlimited
Snapshot create time          : Thu Jul 01 15:03:22 2004
Copy-on-write granularity     : 32 KB</screen>
</step>
</procedure>
</task><sect2 id="bkupsnapshot-4"><title>Deleting a UFS Snapshot</title><para>When you create a UFS snapshot, you can specify that the backing-store
file is unlinked. An unlinked backing-store file is removed after the snapshot
is deleted. If you don't specify the <option>o unlink</option> option when
you create a UFS snapshot, you must manually delete the backing-store file.</para><para>The backing-store file occupies disk space until the snapshot is deleted,
whether you use the <option>o unlink</option> option to remove the backing-store
file or you manually delete the file.</para>
</sect2><task id="bkupsnapshot-8"><title>How to Delete a UFS Snapshot</title><tasksummary><para>You can delete a snapshot either by rebooting the system or by using
the <command>fssnap -d</command> command. When you use this command, you must
specify the path of the file system that contains the UFS snapshot.</para>
</tasksummary><procedure><step id="filesystem-step-6"><para>Become superuser or assume an equivalent
role.</para>
</step><step id="bkupsnapshot-step-26"><para>Identify the snapshot to be deleted.</para><screen># <userinput>/usr/lib/fs/ufs/fssnap -i</userinput></screen>
</step><step id="bkupsnapshot-step-28"><para>Delete the snapshot.</para><screen># <userinput>fssnap -d</userinput> <replaceable>/file-system</replaceable>
Deleted snapshot 1.</screen>
</step><step id="bkupsnapshot-step-31"><para>If you did not use the <option>o unlink</option> option
when you created the snapshot, manually delete the backing-store file.</para><screen># <userinput>rm</userinput> <replaceable>/file-system/backing-store-file</replaceable></screen>
</step>
</procedure><example id="fncpu"><title>Deleting a UFS Snapshot</title><para>The following example shows how to delete a snapshot and assumes
that the <option>o unlink</option> option was not used.</para><screen># <userinput>fssnap -i</userinput>
    0    /export/home
    1    /export
   # <userinput>fssnap -d /usr</userinput>
 Deleted snapshot 1.
# <userinput>rm /var/tmp/export.snap0</userinput></screen>
</example>
</task>
</sect1><sect1 id="bkupsnapshot-9"><title>Backing Up a UFS Snapshot</title><para>You can create a full backup or an incremental backup of a UFS snapshot.
You can use the standard Solaris backup commands to back up a UFS snapshot.</para><para>The virtual device that contains the UFS snapshot acts as a standard
read-only device. So, you can back up the virtual device as if you were backing
up a file system device. </para><para>If you are using the <command>ufsdump</command> command to back up a
UFS snapshot, you can specify the snapshot name during the backup. See the
following procedure for more information.</para><task id="bkupsnapshot-10"><title>How to Create a Full Backup of a UFS Snapshot
(<command>ufsdump</command>)</title><procedure><step id="filesystem-step-7"><para>Become superuser or assume an equivalent role.</para>
</step><step id="bkupsnapshot-step-1"><para>Identify the UFS snapshot to be backed
up.</para><screen># <userinput>/usr/lib/fs/ufs/fssnap -i</userinput> <replaceable>/file-system</replaceable>
 </screen><para>For example:</para><screen># <userinput>/usr/lib/fs/ufs/fssnap -i /usr</userinput>
Snapshot number               : 1
Block Device                  : /dev/fssnap/1
Raw Device                    : /dev/rfssnap/1
Mount point                   : /usr
Device state                  : idle
Backing store path            : /var/tmp/usr.snap0
Backing store size            : 0 KB
Maximum backing store size    : Unlimited
Snapshot create time          : Thu Jul 01 15:17:33 2004
Copy-on-write granularity     : 32 KB</screen>
</step><step id="bkupsnapshot-step-13"><para>Back up the UFS snapshot.</para><screen># <userinput>ufsdump 0ucf /dev/rmt/0</userinput> <replaceable>/snapshot-name</replaceable></screen><para>For example:</para><screen># <userinput>ufsdump 0ucf /dev/rmt/0 /dev/rfssnap/1</userinput> </screen>
</step><step id="bkupsnapshot-step-14"><para>Verify that the snapshot has been backed
up.</para><para>For example:</para><screen># <userinput>ufsrestore tf /dev/rmt/0</userinput></screen>
</step>
</procedure>
</task><task id="bkupsnapshot-16"><title>How to Create an Incremental Backup of a
UFS Snapshot (<command>ufsdump</command>)</title><tasksummary><para>Backing up a UFS snapshot incrementally means that only the files that
have been modified since the last snapshot are backed up. Use the <command>ufsdump</command> command with the <command>N</command> option. This option specifies
the file system device name to be inserted into the <filename>/etc/dumpdates</filename> file
for tracking incremental dumps.</para><para>The following <command>ufsdump</command> command specifies an embedded <command>fssnap</command> command to create an incremental backup of a file system.</para>
</tasksummary><procedure><step id="filesystem-step-8"><para>Become superuser or assume an equivalent
role.</para>
</step><step id="bkupsnapshot-step-30"><para>Create an incremental backup of a UFS
snapshot.</para><para>For example:</para><screen># <userinput>ufsdump 1ufN /dev/rmt/0</userinput> <replaceable>/dev/rdsk/c0t1d0s0</replaceable> <userinput>`fssnap -F ufs -o raw,bs=</userinput>
<replaceable>/export/scratch</replaceable>,<userinput>unlink</userinput> <replaceable>/dev/rdsk/c0t1d0s0</replaceable><userinput>`</userinput></screen><para>In this example, the <option>o raw</option> option is used to display
the name of the raw device instead of the block device. By using this option,
you make it easier to embed the <command>fssnap</command> command in commands
(such as the <command>ufsdump</command> command) that require the raw device
instead.</para>
</step><step id="bkupsnapshot-step-27"><para>Verify that the snapshot has been backed
up.</para><screen># <userinput>ufsrestore ta /dev/rmt/0</userinput></screen>
</step>
</procedure>
</task><task id="bkupsnapshot-12"><title>How to Back Up a UFS Snapshot (<command>tar</command>)</title><tasksummary><para>If you are using the <command>tar</command> command to back up the snapshot,
mount the snapshot before backing it up.</para>
</tasksummary><procedure><step id="bkupsnapshot-step-11"><para>Become superuser or assume an equivalent
role.</para>
</step><step id="bkupsnapshot-step-2"><para>Create a mount point for the snapshot.</para><para>For example:</para><screen># <userinput>mkdir /backups/home.bkup</userinput></screen>
</step><step id="bkupsnapshot-step-15"><para>Mount the snapshot.</para><screen># <userinput>mount -F ufs -o ro /dev/fssnap/1 /backups/home.bkup</userinput></screen>
</step><step id="bkupsnapshot-step-8"><para>Change to the mounted snapshot directory.</para><screen># <userinput>cd /backups/home.bkup</userinput></screen>
</step><step id="bkupsnapshot-step-9"><para>Back up the snapshot with the <command>tar</command> command.</para><screen># <userinput>tar cvf /dev/rmt/0 .</userinput></screen>
</step>
</procedure>
</task><sect2 id="bkupsnapshot-15"><title>Restoring Data From a UFS Snapshot Backup</title><para>The backup created from the virtual device is essentially just a backup
of what the original file system looked like when the snapshot was taken.
When you restore a file system from the backup, restore as if you had taken
the backup directly from the original file system. Such a restore uses the <command>ufsrestore</command> command. For information on using the <command>ufsrestore</command> command
to restore a file or file system, see <olink targetptr="bkuprestoretasks-38055" remap="internal">Chapter&nbsp;26, Restoring Files and File Systems (Tasks)</olink>.</para>
</sect2>
</sect1>
</chapter>