Skip to content

How-to

Volume snapshots

Take a snapshot of a volume before a risky change, restore it to a new volume if the change goes wrong, and delete snapshots you no longer need.

A snapshot is a copy of a volume at one point in time. It's quick to take, and it's kept on the same storage as the volume, so it's a way to roll back, not a backup: for a copy that survives the loss of the volume, back it up. A volume with snapshots can't be deleted until they are.

Before you start

  • A volume, attached or not.
  • For a consistent snapshot of an attached volume, stop writes to it first. On Linux, flush and freeze the filesystem, take the snapshot, then thaw it:

    sudo sync
    sudo fsfreeze -f /mnt/data
    # take the snapshot
    sudo fsfreeze -u /mnt/data
    

    Writes to the filesystem wait while it's frozen, so keep it short. On Windows, or for a database, use the application's own backup, or shut the instance down: see Reliability.

Take a snapshot

  1. In the Breqwatr Cloud Portal (Strata), open Volumes and choose the volume.
  2. Choose Snapshot.
  3. Keep the Snapshot name the portal suggests, the volume's name and today's date, or enter your own, such as data-volume-before-upgrade. Add a Description if you like.
  4. Choose Create snapshot.

The Create snapshot dialog on data-volume's page, with data-volume-before-upgrade as the snapshot name

The snapshot appears under Snapshots on the volume's page, and on the project's Snapshots page. An instance's page has a Snapshot action for each of its volumes too.

openstack --os-cloud <cloud-name> --os-volume-api-version 3.66 volume snapshot create --volume data-volume data-volume-before-upgrade

Version 3.66 of the volume API allows a snapshot of an attached volume. Without --os-volume-api-version 3.66, the command fails for an attached volume with "status must be available".

OpenTofu has no resource that takes a volume snapshot. Take it with the portal or the CLI.

The snapshot is ready when its status is Available.

Restore from a snapshot

A snapshot isn't restored over its volume. You make a new volume from it, then attach the new volume in place of the old one, or alongside it to copy files back.

  1. Open Snapshots and choose Create volume on the snapshot's row.
  2. Enter a Name, such as data-volume-restored. The size is fixed to the snapshot's.
  3. Choose Create volume.
openstack --os-cloud <cloud-name> volume create data-volume-restored --snapshot data-volume-before-upgrade

Add --size to make the new volume larger than the snapshot.

data "openstack_blockstorage_snapshot_v3" "before_upgrade" {
  name = "data-volume-before-upgrade"
}

resource "openstack_blockstorage_volume_v3" "data_restored" {
  name        = "data-volume-restored"
  size        = data.openstack_blockstorage_snapshot_v3.before_upgrade.size
  snapshot_id = data.openstack_blockstorage_snapshot_v3.before_upgrade.id
}

Then attach the new volume. It already has the filesystem, so mount it without formatting. Its filesystem has the same UUID as the original's: to attach both to one instance, mount the copy by its device name, such as sudo mount -o ro /dev/vdc /mnt/restore, not by UUID.

Delete a snapshot

Open Snapshots, or the volume's page, and choose Delete on the snapshot's row. Type CONFIRM and choose Delete snapshot. Volumes already made from it aren't affected.

openstack --os-cloud <cloud-name> volume snapshot list --volume data-volume
openstack --os-cloud <cloud-name> volume snapshot delete data-volume-before-upgrade

Delete it with the portal or the CLI.

A snapshot counts against your project's storage quota at its volume's size until you delete it, so delete each one once the change it protected has worked.

Check it worked

  • openstack --os-cloud <cloud-name> volume snapshot list shows the snapshot, its size and the status available.
  • A volume made from it holds the data as it was when you took the snapshot.