.. _Managing LUN Snapshots:

Managing LUN Snapshots
----------------------

As with virtual machines, you can create and manage snapshots of LUNs. At that, to create a snapshot of the entire target, you will need to create snapshots of each LUN within it.

.. _Creating LUN Snapshots:

Creating LUN Snapshots
~~~~~~~~~~~~~~~~~~~~~~

To create a snapshot of a LUN in an iSCSI target, use the ``vstorage-iscsi snapshot-create`` command. For example, for LUN 1 on target ``iqn.2014-04.com.vstorage:test1``:

::

    # vstorage-iscsi snapshot-create -t iqn.2014-04.com.vstorage:test1 -l 1
    Snapshot a1f54314-bc06-40c6-a587-965feb9d85bb successfully created.

.. note:: To generate a UUID manually, use ``uuidgen``.

.. _Listing LUN Snapshots:

Listing LUN Snapshots
~~~~~~~~~~~~~~~~~~~~~

To list snapshots for the specified LUN, use the ``vstorage-iscsi snapshot-list`` command. For example, for LUN 1 on ``target iqn.2014-04.com.vstorage:test1``:

::

    # vstorage-iscsi snapshot-list -t iqn.2014-04.com.vstorage:stor4 -l 1
    CREATED             C UUID                                 PARENT_UUID                        
    2014-04-11 13:16:51   a1f54314-bc06-40c6-a587-{...} 00000000-0000-0000-{...}
    2014-04-11 13:16:57 * 9c98b442-7482-4fd0-9c45-{...} a1f54314-bc06-40c6-{...}

In the output above, the asterisk in the column ``C`` indicates the current snapshot, while the column ``PARENT_UUID`` shows snapshot dependency or history.

.. _Switching Between LUN Snapshots:

Switching Between LUN Snapshots
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To switch to the specified LUN snapshot, use the ``vstorage-iscsi snapshot-switch`` command. For example:

::

    # vstorage-iscsi snapshot-switch -u a1f54314-bc06-40c6-a587-965feb9d85bb

After you switch to a snapshot, the current LUN image will be removed.

.. note:: You can only switch between snapshots, if the LUN is offline.

.. _Viewing LUN Snapshot Information:

Viewing LUN Snapshot Information
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To view information about the specified snapshot, use the ``vstorage-iscsi snapshot-info`` command. For example:

::

    # vstorage-iscsi snapshot-info -u 9c98b442-7482-4fd0-9c45-9259374ca84e
    Target: iqn.2014-04.com.vstorage:stor4
    LUN: 1
    Created: 2014-04-11 13:16:57
    Parent: 00000000-0000-0000-0000-000000000000}
    {a1f54314-bc06-40c6-a587-965feb9d85bb}
    {9c98b442-7482-4fd0-9c45-9259374ca84e
    Description: None

.. _Deleting LUN Snapshots:

Deleting LUN Snapshots
~~~~~~~~~~~~~~~~~~~~~~

To delete the specifed LUN snapshot, use the ``vstorage-iscsi snapshot-delete`` command. For example:

::

    # vstorage-iscsi snapshot-delete -u a1f54314-bc06-40c6-a587-965feb9d85bb

If the snapshot has no any children, it will be deleted. If the snapshot has a single child, it will be merged to that child.

.. note::

   1. You can only delete offline snapshots.

   2. Deleting a snapshot that has multiple children is currently not supported.

