LDP/LDP/guide/docbook/EVMSUG/create-snapshot.xml

466 lines
19 KiB
XML

<chapter id="evmscreatesnap"><title>Creating snapshots</title>
<para>This chapter discusses snapshotting and tells how to create
a snapshot.</para>
<sect1 id="whatissnapshotting"><title>What is a snapshot?</title>
<para>A snapshot represents a frozen image of a volume.
The source of a snapshot is
called an &quot;original.&quot;
When a snapshot is created, it looks exactly like the original
at that point in time.
As changes are made to the original, the snapshot remains the
same and looks exactly like the original at the time the snapshot was
created.
</para>
<para>
Snapshotting allows you to keep a volume online while a backup is created.
This method is much more convenient than a data backup where a volume
must be taken offline to perform a consistent backup.
When snapshotting, a snapshot of the volume is created and the backup
is taken from the snapshot, while the original remains in active use.
</para>
</sect1>
<sect1 id="createactivsnap"><title>Creating snapshot objects</title>
<para>You can create a snapshot object from any unused storage object in EVMS
(disks, segments, regions, or feature objects).
The size of this consumed object is
the size available to the snapshot object. The snapshot object can be smaller
or larger than the original volume.
If the object is smaller, the snapshot volume could fill up as data is copied
from the original to the snapshot, given sufficient activity on the original.
In this situation, the snapshot is deactivated and additional
I/O to the snapshot fails.
</para>
<para>Base the size of the snapshot object on the amount of activity that
is likely to take place on the original during the lifetime of the snapshot.
The more changes that occur on the
original and the longer the snapshot is expected to remain active,
the larger the snapshot object should be.
Clearly, determining this calculation is not simple and requires trial and
error to determine the correct snapshot object size to use for a
particular situation.
The goal is to create a snapshot object large enough to prevent the
shapshot from being
deactivated if it fills up, yet small enough to not waste disk space.
If the snapshot
object is the same size as the original volume, or a little larger,
to account for the snapshot mapping tables, the snapshot is
never deactivated.
</para>
<para>After you've created the snapshot object and saved the changes, the
snapshot will be activated (as long as the snapshot child object is already active).
This is a change from snapshots in EVMS 2.3.x and earlier, where the snapshot
would not be activated until the object was made into an EVMS volume. If you
wish to have an inactive snapshot, please add the name of the snapshot object
to the &quot;activate.exclude&quot; line in the EVMS configuration file (see section about
selective-activation for more details). If at any point you decide to deactivate a
snapshot object while the original volume is still active, the snapshot will be reset.
The next time that the snapshot object is activated, it will reflect the state of the
original volume at that point in time, just as if the snapshot had just been created.</para>
<para>In order to mount the snapshot, the snapshot object must still be made into an
EVMS volume. The name of this volume can be the same as or different than the
name of the snapshot object.</para>
</sect1>
<sect1 id="snapshotex"><title>Example: create a snapshot</title>
<para> This section shows how to create a snapshot with EVMS:</para>
<blockquote><example><title>Create a snapshot of a volume</title>
<para>Create a new snapshot of <filename>/dev/evms/vol</filename> on
<filename>lvm/Sample Container/Sample Region</filename>, and call
it &quot;snap.&quot;</para></example></blockquote>
<sect2 id="guisnapshot"><title>Using the EVMS GUI</title>
<para>To create the snapshot using the GUI, follow these steps:
<orderedlist>
<listitem><para>Select
<menuchoice>
<guimenu>Actions</guimenu>
<guimenuitem>Create</guimenuitem>
<guimenuitem>Feature Object</guimenuitem>
</menuchoice>
to see a list of EVMS feature objects.
</para></listitem>
<listitem><para>Select
<guimenuitem>Snapshot Feature</guimenuitem>.
</para></listitem>
<listitem><para>Click <guibutton>Next</guibutton>.</para></listitem>
<listitem><para>Select <guimenuitem>lvm/Sample Container/Sample Region</guimenuitem>. </para></listitem>
<listitem><para>Click <guibutton>Next</guibutton>.</para></listitem>
<listitem><para>Select <guimenuitem>/dev/evms/vol</guimenuitem> from the list in the
&quot;Volume to be Snapshotted&quot; field.</para></listitem>
<listitem><para>Type <filename>snap</filename> in the &quot;Snapshot Object Name&quot; field.
</para></listitem>
<listitem><para>Click <guibutton>Create</guibutton>.
</para></listitem>
</orderedlist></para>
<para>Alternatively, you can perform some of the steps to create a snapshot with the GUI
context sensitive menu:</para>
<orderedlist>
<listitem><para>From the <guimenuitem>Available Objects</guimenuitem> tab, right click
<guimenuitem>lvm/Sample Container/Sample Region</guimenuitem>.</para></listitem>
<listitem><para>Click <guimenuitem>Create Feature Object...</guimenuitem></para></listitem>
<listitem><para>Continue creating the snapshot beginning with step 2 of the
GUI instructions. You can skip steps 4 and 5 of the GUI instructions.</para></listitem>
</orderedlist>
</sect2>
<!-- Ncurses-->
<sect2 id="ncursnapshot"><title>Using Ncurses</title>
<para>To create the snapshot, follow these steps:</para>
<orderedlist><listitem><para>Select <menuchoice><guimenu>Actions</guimenu><guimenuitem>Create</guimenuitem>
<guimenuitem>Feature Object</guimenuitem></menuchoice>
to see a list of EVMS feature objects.</para> </listitem>
<listitem><para>Select <guimenuitem>Snapshot Feature</guimenuitem>.</para>
</listitem>
<listitem><para>Activate <guibutton>Next</guibutton>.</para></listitem>
<listitem><para>Select <filename>lvm/Sample Container/Sample Region.</filename></para></listitem>
<listitem><para>Activate <guibutton>Next</guibutton>.</para></listitem>
<listitem><para>Press
<keycap>spacebar</keycap> to edit the &quot;Volume to be Snapshotted&quot; field.</para></listitem>
<listitem><para>Highlight <filename>/dev/evms/vol</filename> and press <keycap>spacebar</keycap> to select.</para></listitem>
<listitem><para>Activate <guibutton>OK</guibutton>.</para></listitem>
<listitem><para>Highlight &quot;Snapshot Object Name&quot; and press <keycap>spacebar</keycap> to edit.</para></listitem>
<listitem><para>Type <userinput>snap</userinput> at the "::" prompt.
Press <keycap>Enter</keycap>.</para></listitem>
<listitem><para>Activate <guibutton>Create</guibutton>.</para></listitem>
</orderedlist>
<para>Alternatively, you can perform some of the steps to create a snapshot with the
context sensitive menu:</para>
<orderedlist>
<listitem><para>From the Available Objects view, press <keycap>Enter</keycap> on <filename>lvm/Sample Container/Sample Region</filename>.</para>
</listitem>
<listitem><para>Activate the <guimenuitem>Create Feature Object</guimenuitem> menu item.</para>
</listitem>
<listitem><para>Continue creating the snapshot beginning with step 6 of the Ncurses
instructions.</para>
</listitem>
</orderedlist>
</sect2>
<!-- CLI-->
<sect2 id="clisnapshot"><title>Using the CLI</title>
<para>Use the
<command>create</command> command to create a snapshot through the CLI. You pass the &quot;Object&quot; keyword to the <command>create</command> command, followed by the plug-in and its options, and finally the objects. </para>
<para>To determine the options for the plug-in you are going to use, issue the following command:</para>
<programlisting>query: plugins, plugin=Snapshot, list options</programlisting>
<para>Now construct the <command>create</command> command, as follows:</para>
<programlisting>create: object, Snapshot={original=/dev/evms/vol, snapshot=snap},
&quot;lvm/Sample Container/Sample Region&quot;</programlisting>
</sect2>
</sect1>
<sect1><title>Reinitializing a snapshot</title>
<para>Snapshots can be reinitialized. Reinitializing causes all of the
saved data to be erased and
starts the snapshot from the current point in time.
A reinitialized snapshot has the same
original, chunk size, and writeable flags as the original
snapshot.</para>
<para>To reinitialize a snapshot, use the <command>Reset</command>
command on the snapshot object
(not the snapshot volume).
This command reinitializes the snapshot without requiring you to
manually deactivate and reactivate the volume.
The snapshot must be active but unmounted for it to be reinitialized.
</para>
<para>This section continues the example from the previous section,
where a snapshot object and volume were created.
The snapshot object is called &quot;snap&quot; and the volume
is called &quot;/dev/evms/snap.&quot;</para>
<sect2><title>Using the EVMS GUI or Ncurses</title>
<para>To reinitialize a snapshot, follow these steps:
<orderedlist>
<listitem><para>Select
<menuchoice>
<guimenu>Actions</guimenu>
<guimenuitem>Other</guimenuitem>
<guimenuitem>Storage Object Tasks</guimenuitem>
</menuchoice>
</para></listitem>
<listitem><para>Select the volume "snap."</para></listitem>
<listitem><para>Click or activate <guibutton>Next</guibutton>.</para></listitem>
<listitem><para>Select <guibutton>Reset</guibutton>.</para></listitem>
<listitem><para>Click or activate <guibutton>Next</guibutton>.</para></listitem>
<listitem><para>Click or activate <guibutton>Reset</guibutton> on the action panel.
</para></listitem>
<listitem><para>Click or activate <guibutton>Reset</guibutton> on the warning panel.</para></listitem>
</orderedlist>
</para>
<para>Alternatively, you can perform these same steps with the context sensitive menus:</para>
<orderedlist>
<listitem><para>From the Feature Objects panel, right click (or press <keycap>Enter</keycap> on)
the object <guimenuitem>snap</guimenuitem>.
</para>
</listitem>
<listitem><para>Click or activate <guibutton>Reset</guibutton> on the popup menu.</para></listitem>
<listitem><para>Click or activate <guibutton>Reset</guibutton> on the action panel.</para></listitem>
<listitem><para>Click or activate <guibutton>Reset</guibutton> on the warning panel.</para></listitem>
</orderedlist>
</sect2>
<sect2><title>Using the CLI</title>
<para>Follow these steps to reinitialize a snapshot with the CLI:</para>
<orderedlist>
<listitem><para>Issue the following command to the CLI:</para>
<programlisting>task:reset,snap</programlisting>
</listitem>
<listitem><para>Press <keycap>Enter</keycap> to select &quot;Reset&quot; (the default choice) at the warning message.</para>
</listitem>
</orderedlist>
</sect2>
</sect1>
<sect1><title>Expanding a snapshot</title>
<para>
As mentioned in <xref linkend="createactivsnap"></xref>, as data is
copied from the original volume to the snapshot, the space available
for the snapshot might fill up, causing the snapshot to be invalidated.
This situation might cause your data backup to end prematurely, as the
snapshot volume begins returning I/O errors after it is invalidated.
</para>
<para>
To solve this problem, EVMS now has the ability to expand the storage
space for a snapshot object while the snapshot volume is active and mounted.
This feature allows you to initially create a small snapshot object and expand
the object as necessary as the space begins to fill up.
</para>
<para>
In order to expand the snapshot object, the underlying object must
be expandable.
Continuing the example from the previous sections, the object "snap" is
built on the LVM region <filename>lvm/Sample Container/Sample Region</filename>.
When we refer to expanding the "snap" object, the region
<filename>lvm/Sample Container/Sample Region</filename> is the
object that actually gets
expanded, and the object "snap" simply makes use of the new space on
that region.
Thus, to have expandable snapshots, you will usually want to build
your snapshot objects on top of LVM regions that have extra freespace
available in their LVM container. DriveLink objects and some disk
segments also work in certain situations.
</para>
<para>
One notable quirk about expanding snapshots is that the snapshot
object and volume do not actually appear to expand after the operation
is complete.
Because the snapshot volume is supposed to be a frozen image of the original
volume, the snapshot volume always has the same size as the original,
even if the snapshot has been expanded.
However, you can verify that the snapshot object is using the
additional space by displaying the details for the snapshot object
and comparing the percent-full field before and after the expand operation.
</para>
<sect2><title>Using the EVMS GUI or Ncurses</title>
<para>To create the snapshot using the GUI or Ncurses, follow these steps:
<orderedlist>
<listitem><para>Select
<menuchoice>
<guimenu>Actions</guimenu>
<guimenuitem>Expand</guimenuitem>
<guimenuitem>Volume</guimenuitem>
</menuchoice>
to see a list of EVMS feature objects.
</para></listitem>
<listitem><para>Select the volume <guimenuitem>/dev/evms/snap</guimenuitem>.</para></listitem>
<listitem><para>Click or activate <guibutton>Next</guibutton>.</para></listitem>
<listitem><para>Select <guimenuitem>lvm/Sample Container/Sample Region</guimenuitem>.
This object is the object that will actually be expanded. </para></listitem>
<listitem><para>Click or activate <guibutton>Next</guibutton>.</para></listitem>
<listitem><para>Select the options for expanding the LVM region,
including the amount of extra space to add to the region.
</para></listitem>
<listitem><para>Click or activate <guibutton>Expand</guibutton>.
</para></listitem>
</orderedlist></para>
<para>Alternatively, you can perform the same steps using the context sensitive menus.</para>
<orderedlist>
<listitem><para>From the <guilabel>Volumes</guilabel> panel, right click (or press <keycap>Enter</keycap> on)
<guimenuitem>/dev/evms/snap</guimenuitem>.
</para>
</listitem>
<listitem><para>Select <guibutton>Expand</guibutton> from the popup menu.</para></listitem>
<listitem><para>Click or activate <guibutton>Next</guibutton>.</para></listitem>
<listitem><para>Select the region <guimenuitem>lvm/Sample Container/Sample Region</guimenuitem>. This is the object that will
actually be expanded.</para></listitem>
<listitem><para>Click or activate <guibutton>Next</guibutton>.</para></listitem>
<listitem><para>Select the options for expanding the LVM region, including the
amount of extra space to add to the region.</para></listitem>
<listitem><para>Click or activate <guibutton>Expand</guibutton>.</para>
</listitem>
</orderedlist>
</sect2>
<sect2><title>Using the CLI</title>
<para>The CLI expands volumes by targeting the object to be
expanded.
The CLI automatically handles expanding the volume and other objects above the volume
in the volume stock. As with a regular expand operation, the options are determined
by the plug-in that owns the object being expanded.</para>
<para>Issue the following command to determine the expand options for the
region <filename>lvm/Sample Container/Sample Region</filename>:</para>
<programlisting>query:region,region=&quot;lvm/Sample Container/Sample Region&quot;,lo</programlisting>
<para>The option to use for expanding this region is called &quot;add_size.&quot;
Issue the following command to expand the snapshot by 100 MB:</para>
<programlisting>expand:&quot;lvm/Sample Container/Sample Region&quot;, add_size=100MB</programlisting>
</sect2>
</sect1>
<sect1><title>Deleting a snapshot</title>
<para>When a snapshot is no longer needed, you can remove it by deleting the EVMS
volume from the snapshot object, and then deleting the snapshot object. Because the
snapshot saved the initial state of the original volume (and not the changed state),
the original is always up-to-date and does not need any modifications when a snapshot
is deleted.</para>
<para>No options are available for deleting snapshots.</para>
</sect1>
<sect1><title>Rolling back a snapshot</title>
<para>Situations can arise where a user wants to restore the original volume to
the saved state of the snapshot. This action is called a rollback. One such scenario
is if the data on the original is lost or corrupted. Snapshot rollback acts as a quick
backup and restore mechanism, and allows the user to avoid a more lengthy restore
operation from tapes or other archives.</para>
<para>Another situation where rollback can be particularly useful is when you are
testing new software. Before you install a new software package, create a writeable
snapshot of the target volume. You can then install the software to the snapshot
volume, instead of to the original, and then test and verify the new software on the
snapshot. If the testing is successful, you can then roll back the snapshot to the
original and effectively install the software on the regular system. If there is a problem
during the testing, you can simply delete the snapshot without harming the original
volume.</para>
<para>You can perform a rollback when the following conditions are met:
</para>
<itemizedlist>
<listitem>
<para>
Both the snapshot and the original volumes
are unmounted and otherwise not in use.
</para>
</listitem>
<listitem>
<para>
There is only a single snapshot of an original.</para>
<para>
If an original has multiple snapshots,
all but the desired snapshot must be deleted before rollback can take place.
</para>
</listitem>
</itemizedlist>
<para>No options are available for rolling back snapshots.</para>
<sect2><title>Using the EVMS GUI or Ncurses</title>
<para>Follow these steps to roll back a snapshot with the EVMS GUI or Ncurses:</para>
<orderedlist>
<listitem><para>Select
<menuchoice><guimenu>Actions</guimenu>
<guimenuitem>Other</guimenuitem>
<guimenuitem>Storage Object Tasks</guimenuitem>
</menuchoice>.</para></listitem>
<listitem><para>Select the object "snap."</para></listitem>
<listitem><para>Click or activate <guibutton>Next</guibutton>.</para></listitem>
<listitem><para>Select <guibutton>Rollback</guibutton>.</para></listitem>
<listitem><para>Click or activate <guibutton>Next</guibutton>.</para></listitem>
<listitem><para>Click or activate <guibutton>Rollback</guibutton> on the action panel.
</para></listitem>
<listitem><para>Click or activate <guibutton>Rollback</guibutton> on the warning panel.
</para></listitem>
</orderedlist>
<para>Alternatively, you can perform these same steps with the context-sensitive menus:</para>
<orderedlist>
<listitem><para>From the Feature Objects panel, right click (or press
<keycap>Enter</keycap> on) the object &quot;snap.&quot;</para>
</listitem>
<listitem><para>Click or activate <guibutton>Rollback</guibutton> on the popup menu.</para>
</listitem>
<listitem><para>Click or activate <guibutton>Rollback</guibutton> on the action panel.</para>
</listitem>
<listitem><para>Click or activate <guibutton>Rollback</guibutton> on the warning panel.</para>
</listitem>
</orderedlist>
</sect2>
<sect2><title>Using the CLI</title>
<para>Follow these steps to roll back a snapshot with the CLI:</para>
<orderedlist>
<listitem><para>Issue the following command to the CLI:</para>
<programlisting>task:rollback,snap</programlisting>
</listitem>
<listitem><para>Press <keycap>Enter</keycap> to select &quot;Rollback&quot; (the default choice) at the warning message.</para>
</listitem>
</orderedlist>
</sect2>
</sect1>
</chapter>