Managing volume snapshots

You can save the current state of a VM file system or user data by creating a snapshot of a volume. A snapshot of a boot volume may be useful, for example, before updating VM software. If anything goes wrong, you will be able to revert the VM to a working state at any time. A snapshot of a data volume can be used for backing up user data and testing purposes.

Prerequisites

  • To create a consistent snapshot of a running VM’s volume, the guest tools must be installed in the VM, as described in Installing guest tools. The QEMU guest agent included in the guest tools image automatically quiesces the filesystem during snapshotting.

To create a snapshot of a volume

Admin panel

  1. On the Compute > Storage > Volumes tab, click a volume.
  2. In the volume right pane, switch to Snapshots, and then click Create snapshot.

Command-line interface

Use the following command:

vinfra service compute volume snapshot create [--description <description>]
                                              --volume <volume> <volume-snapshot-name>
--description <description>
Volume snapshot description
--volume <volume>
Volume ID or name
<volume-snapshot-name>
Volume snapshot name

For example, to create a snapshot mysnapshot of the volume myvolume, run:

# vinfra service compute volume snapshot create mysnapshot --volume myvolume
+-------------+--------------------------------------+
| Field       | Value                                |
+-------------+--------------------------------------+
| created_at  | 2019-04-30T13:12:54.297629+00:00     |
| description |                                      |
| id          | 3fdfe5d6-8bd2-4bf5-8599-a9cef50e5b71 |
| metadata    | {}                                   |
| name        | mysnapshot                           |
| project_id  | fd0ae61496d04ef6bb637bc3167b7eaf     |
| size        | 8                                    |
| status      | creating                             |
| volume_id   | 92dc3bd7-713d-42bf-83cd-4de40c24fed9 |
+-------------+--------------------------------------+

The new snapshot will appear in the vinfra service compute volume snapshot list output:

# vinfra service compute volume snapshot list -c id -c name -c size -c status
+--------------------------------------+------------+-----------+
| id                                   | name       | status    |
+--------------------------------------+------------+-----------+
| 3fdfe5d6-8bd2-4bf5-8599-a9cef50e5b71 | mysnapshot | available |
+--------------------------------------+------------+-----------+

To manage a volume snapshot

Admin panel

Select a volume and open the Snapshots tab on its right pane.

You can do the following:

  • Create a new volume from the snapshot.
  • Create a template from the snapshot.
  • Discard all changes that have been made to the volume since the snapshot was taken. This action is available only for VMs with the "Shut down" and "Shelved offloaded" statuses.

    As each volume has only one snapshot branch, all snapshots created after the snapshot you are reverting to will be deleted. If you want to save a subsequent snapshot before reverting, create a volume or an image from it first.

  • Change the snapshot name and description.
  • Reset the snapshot stuck in an "Error" state or transitional state to the "Available" state.
  • Remove the snapshot.

To perform these actions, click the ellipsis button next to a snapshot, and then click the corresponding action.

Command-line interface

Use the following commands:

  • To revert a volume to the snapshot, use vinfra service compute volume snapshot revert. For example:

    # vinfra service compute volume snapshot revert mynewsnapshot
  • To create a template from the snapshot, use vinfra service compute volume snapshot upload-to-image. For example:

    # vinfra service compute volume snapshot upload-to-image --name myvm-image mysnapshot
    
  • To create a new volume from the snapshot, use vinfra service compute volume create. For example:

    # vinfra service compute volume create myvolume2 --snapshot mysnapshot --storage-policy default --size 8
  • To change the snapshot name and description, use vinfra service compute volume snapshot set. For example:

    # vinfra service compute volume snapshot set mysnapshot --name mynewsnapshot \
    --description "My new snapshot"
    
  • To reset the snapshot stuck in an "Error" state or transitional state to the "Available" state, use vinfra service compute volume snapshot reset-state. For example:

    # vinfra service compute volume snapshot reset-state mysnapshot
  • To remove the snapshot, use vinfra service compute volume snapshot delete. For example:

    # vinfra service compute volume snapshot delete mynewsnapshot