Skip to content

Volume Snapshots

This section covers the snapshot functionality for block volumes attached to a VM.

If you are interested in snapshoting the system disk of a VM, refer to documentation in Using OpenStack.


A snapshot is an immutable, point-in-time consistent version of a volume. It can be used to create other volumes from it or to rollback to a previous state of the data stored. The creation of a snapshot is fast (takes a few seconds) and it can be done while the volume is in-use by passing the --force flag.

Note:

  • Snapshots produce an immutable, point-in-time consistent version of a volume. If at the time of snapshotting the volume is in use and an application performs IO on it, only the data that has already been flushed to the volume is captured. In-memory data or write operations not transfered to the volume (e.g., in-cache dirty data) is not part of the snapshot.
  • To achieve application consistency, all required data must be written to the volume before the snapshot is made. This can be accomplished with fsfreeze, which will suspend access to the file system and sync uncommitted changes to the volume. Freezing a filesystem may take time (even minutes) during which writes (and other call that may modify the filesystem content), which can lead applications to stall. Alternatively, one can detach the volume from the VM (see Detaching a volume) or power this latter off.

Creating volume snapshots

$ openstack volume snapshot create --volume timvol143 timvolsnap143
+-------------+--------------------------------------+
| Field       | Value                                |
+-------------+--------------------------------------+
| created_at  | 2020-12-10T09:16:45.749407           |
| description | None                                 |
| id          | 7c63c503-8cb5-40bd-b434-9b638ecb4fc3 |
| name        | timvolsnap143                        |
| properties  |                                      |
| size        | 1                                    |
| status      | creating                             |
| updated_at  | None                                 |
| volume_id   | f3709518-b67b-49a8-ad03-0ba5f115ab67 |
+-------------+--------------------------------------+

You can list the volume snapshots with the following command

$ openstack volume snapshot list
+--------------------------------------+---------------+-------------+-----------+------+
| ID                                   | Name          | Description | Status    | Size |
+--------------------------------------+---------------+-------------+-----------+------+
| 7c63c503-8cb5-40bd-b434-9b638ecb4fc3 | timvolsnap143 | None        | available |    1 |
+--------------------------------------+---------------+-------------+-----------+------+

Creating a new volume from a snapshot

Once the volume snapshot is in state available, it can be used to create other volumes from it. The creation time may depend on the type of the volume you are creating as it may entail data transfer. There is no need to specify the size of the volume as the size of the snapshot will be used.

$ openstack volume create --source timvolsnap143 --description "Volume from a snapshot" timvol143
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| attachments         | []                                   |
| availability_zone   | ceph-geneva-1                        |
| bootable            | false                                |
| consistencygroup_id | None                                 |
| created_at          | 2020-12-10T09:19:45.000000           |
| description         | None                                 |
| encrypted           | False                                |
| id                  | 68fb4e47-39e6-40b5-a12d-371b34989b83 |
| multiattach         | False                                |
| name                | timvol144                            |
| properties          |                                      |
| replication_status  | None                                 |
| size                | 1                                    |
| snapshot_id         | 7c63c503-8cb5-40bd-b434-9b638ecb4fc3 |
| source_volid        | None                                 |
| status              | creating                             |
| type                | standard                             |
| updated_at          | None                                 |
+---------------------+--------------------------------------+

When the volume created from the snapshot is in state available, it can be attached to a VM and used as any other volume. In order to delete a volume created from a snapshot, it may be needed to delete the corresponding snapshot first.

Deleting a snapshot

You can delete the snapshots just by issuing the following command

$ openstack volume snapshot delete timvolsnap143

Note: Deletion cannot be reverted!