Deleting Block Storage for VPC snapshots

You can delete snapshots that you no longer need to free up space for new snapshots. You can delete individual snapshots or all snapshots for a volume.

Prerequisites for deleting snapshots

To be able to delete a snapshot, it must meet the following prerequisites:

  • Be in a stable or pending state.
  • Not be actively restoring a volume.

A convenient way to determine whether you can delete a snapshot is to look in the console for the list of snapshots and check its status.

Deleting snapshots in the console

You can delete any snapshot for a volume or all snapshots for a volume. Deleting all snapshots requires further confirmation in the console.

Deleting a single snapshot in the console

You can delete a snapshot from the list of all snapshots by using the following steps.

  1. Go to the list of all snapshots. In the IBM Cloud console, go to the menu menu icon > Infrastructure VPC icon > Storage > Snapshots.
  2. Click the Actions icon Actions icon in the row of the snapshot that you want to delete.
  3. Select Delete.
  4. Confirm the deletion and click Delete.

You can also delete a snapshot from the details page of a Block Storage for VPC volume.

  1. Go to the list of all Block Storage for VPC volumes. In the IBM Cloud console, click the Navigation menu icon menu icon > Infrastructure VPC icon > Storage > Block Storage volumes.
  2. Select a volume from the list, and click the volume name to go to the volume details page.
  3. Click Snapshots. A list of snapshots that are taken of this volume is displayed, and you can take the following actions:
    • Click Delete all to delete all snapshots for this volume.
    • Click the Actions icon Actions icon to delete a specific snapshot.
  4. Select Delete. If the snapshot is actively restoring a volume, the delete operation does not work.
  5. Confirm the deletion.

Deleting all snapshots for a volume in the console

To delete all snapshots for a volume in the console, follow these steps.

  1. Go to the list of all snapshots. In the IBM Cloud console, go to the menu menu icon > Infrastructure VPC icon > Storage > Snapshots.
  2. Click the row to select the snapshot that you want to delete.
  3. From the Actions menu Actions icon, select Delete all for volume.
  4. Confirm the deletion by typing delete and then click Delete.

Deleting snapshots from the Block Storage for VPC details page in the console

You can delete the most recently created snapshot from the list of snapshots from the Block Storage for VPC volume details page. Optionally, you can delete all snapshots from this view.

  1. Go to the list of all Block Storage for VPC volumes. In the IBM Cloud console, go to the menu menu icon > Infrastructure VPC icon > Storage > Block Storage volumes.
  2. Select a volume from the list and click the volume name to go to the volume details page.
  3. Click Snapshots to see a list of snapshots taken of this volume.
  4. Click Delete all to delete all snapshots for this volume.
  5. Alternatively, select a single snapshot in the list for deletion and then:
    1. Click the Actions icon Actions icon.
    2. Select Delete.
    3. Confirm the deletion.

Deleting snapshots from the CLI

You can delete any snapshot for a volume or all snapshots for a volume from the CLI.

Deleting a single snapshot from the CLI

Use the following steps to delete a single snapshot by using the CLI.

  1. List the snapshots that are available for a volume to confirm the ID of the snapshot that you want to delete.

    ibmcloud is snapshots --volume VOLUME [--resource-group-id RESOURCE_GROUP_ID | --resource-group-name RESOURCE_GROUP_NAME]
    
    $ ibmcloud is snapshots --volume  r010-df8ffd90-f2e5-470b-83d7-76e64995a1aa
    Listing snapshots in all resource groups and region eu-de under account Test Account as user test.user@ibm.com...
    ID                                          Name                             Status   Source volume                               Bootable   Resource group   Created
    r138-7cac80af-63bb-4a1b-83dd-5f6d550a5db7   bear-peroxide-viewable-oxidant   stable   r010-df8ffd90-f2e5-470b-83d7-76e64995a1aa   false      test-snap        2023-02-17T18:49:48+00:00
    r138-4463eb2c-4913-43b1-b9bf-62a94f74c146   cli-snapshot-test                stable   r010-df8ffd90-f2e5-470b-83d7-76e64995a1aa   false      defaults         2023-02-17T20:15:43+00:00
    r138-e6664842-b370-496a-9ae7-da3fb647707c   snappy-snap-snap                 stable   r010-df8ffd90-f2e5-470b-83d7-76e64995a1aa   false      test-snap        2023-02-17T18:53:57+00:00
    
  2. Run the snapshot-delete command and specify the ID of the snapshot. To delete multiple snapshots, you must specify all of their IDs in the same command.

    ibmcloud is snapshot-delete SNAPSHOT_ID
    
  3. Confirm the deletion of the snapshot. The response message indicates that the snapshot is deleted.

    $ ibmcloud is snapshot-delete r138-e6664842-b370-496a-9ae7-da3fb647707c
    This will delete snapshot r138-e6664842-b370-496a-9ae7-da3fb647707c and cannot be undone. Continue [y/N] ?> y
    Deleting snapshot r138-e6664842-b370-496a-9ae7-da3fb647707c under account Test Account as user test.user@ibm.com...
    OK
    Snapshot r138-e6664842-b370-496a-9ae7-da3fb647707c is deleted.
    

For more information about available command options, ibmcloud is snaphot-delete.

Deleting all snapshots from the CLI

Use the following steps to delete all snapshots by using the CLI.

  1. List all snapshots.

    ibmcloud is snapshots --volume VOLUME [--resource-group-id RESOURCE_GROUP_ID | --resource-group-name RESOURCE_GROUP_NAME | --all-resource-groups]
    
  2. Enter the snapshots-delete command and specify the volume ID.

    ibmcloud is snapshots-delete --volume VOLUME_ID
    
  3. Confirm the deletion of the snapshots. The response message indicates when the snapshot deletion request is accepted and the snapshots are being deleted.

    $ ibmcloud is snapshots-delete --volume  r010-df8ffd90-f2e5-470b-83d7-76e64995a1aa
    This will delete snapshot by volume r010-df8ffd90-f2e5-470b-83d7-76e64995a1aa and cannot be undone. Continue [y/N] ?> y
    Deleting snapshot by volume r010-df8ffd90-f2e5-470b-83d7-76e64995a1aa under account Test Account as user test.user@ibm.com...
    OK
    Deletion request for snapshots by volume r010-df8ffd90-f2e5-470b-83d7-76e64995a1aa has been accepted.
    

For more information about available command options, ibmcloud is snaphot-delete.

Deleting snapshots with the API

You can delete any snapshot for a volume or all snapshots for a volume with the API.

Deleting a single snapshot with the API

Make a DELETE /snapshots/{snapshot_ID} call to delete a specific snapshot by ID.

curl -X DELETE \
"$vpc_api_endpoint/v1/snapshots/7528eb61-bc01-4763-a67a-a414a103f96d?version=2022-12-22&generation=2" \
     -H "Authorization: Bearer ${API_TOKEN}"

Deleting all snapshots for a volume with the API

Make a DELETE/snapshots call and specify the source volume ID for the source_volume.id parameter in the request.

curl -X DELETE \
"$vpc_api_endpoint/v1/snapshots?source_volume.id=_volume-id_&version=2022-12-22&generation=2" \
     -H "Authorization: Bearer ${API_TOKEN}"

Deleting snapshots with Terraform

You can delete any snapshot for a volume or all snapshots for a volume with Terraform.

Deleting a single snapshot with Terraform

Use the terraform destroy command to conveniently delete a remote object such as a single snapshot. The following example deletes my-snapshot.

terraform destroy --target ibm_is_snapshot.my-snapshot

For more information, see terraform destroy.

Deleting all snapshots for a volume with Terraform

To delete all snapshots of a volume with terraform, use the ibm_is_volume resource.

resource "ibm_is_volume" "storage" {
  name                 = "example-volume"
  profile              = "general-purpose"
  zone                 = "us-south-1"
  delete_all_snapshots = true
}

For more information about the arguments and attributes, see ibm_is_volume.

Next steps