Create a volume snapshot

Create volume snapshots to preserve volume state at a specific point in time. Snapshots are useful for creating backups before changes, cloning volumes with existing data, or restoring volumes if problems occur. For in-use volumes, use the --force option.

Before you begin

About this task

By default, the maximum number of snapshots you can create for a project is 10. However, the project administrator can change this limit for your project.

Volume backups are different from snapshots. Backups preserve the data contained in the volume, whereas snapshots preserve the state of a volume at a specific point in time. You cannot delete a volume if it has existing snapshots. Volume backups prevent data loss, whereas snapshots facilitate cloning.

For this reason, snapshot back ends are typically colocated with volume back ends to minimize latency during cloning. By contrast, a backup repository is usually located in a different location, for example, on a different node, physical storage, or even geographical location in a typical enterprise deployment. This is to protect the backup repository from any damage that might occur to the volume back end.

Procedure

  1. Access the remote shell for the openstackclient pod from your workstation:
    $ oc rsh -n openstack openstackclient
  2. Create a volume snapshot.
    $ openstack volume snapshot create \
     --volume <volume> \
     [--description <description>] \
     [--force] \
     <snapshot>
    • Replace <volume> with the name or the ID of the volume that you want to create a snapshot of. You can list the available volumes by using the openstack volume list command.
    • Optional: Replace <description> with a concise description of this snapshot, enclosed in double quotes (") when this contains spaces.
    • Optional: If you receive a warning that a volume is in use when creating a snapshot, you can use this --force option to ignore the warning and create the snapshot regardless.
    • Replace <snapshot> with the name of this volume snapshot.

      This command provides a table containing the details of this snapshot. For example:

      +-------------+--------------------------------------+
      | Field       | Value                                |
      +-------------+--------------------------------------+
      | created_at  | 2024-11-12T11:22:40.533557           |
      | description | None                                 |
      | id          | 2ee2cb3d-a59a-473e-a17d-482d7abcd5d5 |
      | name        | MyVol1snap                           |
      | properties  |                                      |
      | size        | 12                                   |
      | status      | creating                             |
      | updated_at  | None                                 |
      | volume_id   | 99510e51-ad60-4d60-b62a-7321e6442f06 |
      +-------------+--------------------------------------+
  3. Exit the openstackclient pod:
    $ exit

Revert a volume to a snapshot

Revert a volume to its most recent snapshot by modifying the existing volume rather than creating a new volume. This approach is faster and more efficient for undoing recent changes or recovering from errors.

Before you begin

  • Block Storage service (cinder) REST API microversion 3.40 or later.
  • You must have created at least one snapshot for the volume.

About this task

Limitations
  • You cannot use the revert-to-snapshot feature on an attached or in-use volume.
  • You cannot use the revert-to-snapshot feature on a bootable root volume because it is not in the available state. To use this feature, the instance must have been booted with the delete_on_termination=false (default) property to preserve the boot volume if the instance is terminated. When you want to revert to a snapshot, you must first delete the initial instance so that the volume is available. You can then revert it and create a new instance from the volume.
  • You cannot revert a volume that you resize (extend) after taking the snapshot.
  • There might be limitations to using the revert-to-snapshot feature with multi-attach volumes. Check whether such limitations apply before you use this feature.

For information about which features your drivers support, contact your driver vendors.

Procedure

  1. Access the remote shell for the openstackclient pod from your workstation:
    $ oc rsh -n openstack openstackclient
  2. Detach your volume:
    $ nova volume-detach <instance_id> <vol_id>
    • Replace <instance_id> with the instance ID.
    • Replace <vol_id> with the volume ID that you want to revert.
  3. Locate the ID or name of the latest snapshot.
    $ openstack volume snapshot-list
  4. Revert the snapshot:
    $ openstack volume --os-volume-api-version=3.40 revert <snapshot_id_name>
    • Replace <snapshot_id_name> with the ID or the name of the snapshot.
  5. Optional: You can check that the volume you are reverting is in a reverting state:
    $ openstack volume snapshot-list
  6. Reattach the volume:
    $ nova volume-attach <instance_id> <vol_id>
  7. Optional: You can use the following command to verify that the volume you reverted is now in an available state.
    $ openstack volume list
  8. Exit the openstackclient pod:
    $ exit

Delete a volume snapshot

You can delete volume snapshots that you no longer need to free up storage space and avoid exceeding your project’s snapshot quota limit. Removing unused snapshots helps you stay within quota limits and maintain capacity for creating new snapshots.

Before you begin

  • A volume snapshot that you want to delete.

About this task

Red Hat OpenStack Services on OpenShift (RHOSO) 18.0 uses the RBD CloneV2 API. When you use Red Hat Ceph Storage as a back end, you can delete volume snapshots even if they have dependencies. If you use an external Ceph Storage back end, you must configure the minimum client on the Ceph Storage cluster. For more information, see Enable deferred deletion for volumes or images with dependencies.

Procedure

  1. Access the remote shell for the openstackclient pod from your workstation:
    $ oc rsh -n openstack openstackclient
  2. Delete the volume snapshot.
    $ openstack volume snapshot delete \
     [--force] \
     <snapshot>
    • Optional: Choose the --force option when deleting a snapshot, to override any normal snapshot state checks.
    • Replace <snapshot> with the name of this volume snapshot that you want to delete. You can list the available snapshots by using the openstack volume snapshot list command. Warning
      There is not undo action that is possible after using this command, so be sure that you are deleting the required snapshot.
  3. Optional: This command does not provide any confirmation that the snapshot has been deleted successfully. You can run the following command to list the available volumes and you should not see the snapshot that you have deleted:
    $ openstack volume snapshot list
  4. Exit the openstackclient pod:
    $ exit