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
stableorpendingstate. - 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.
- Go to the list of all snapshots. In the IBM Cloud console, go to the menu
> Infrastructure
> Storage > Snapshots.
- Click the Actions icon
in the row of the snapshot that you want to delete.
- Select Delete.
- Confirm the deletion and click Delete.
You can also delete a snapshot from the details page of a Block Storage for VPC volume.
- Go to the list of all Block Storage for VPC volumes. In the IBM Cloud console, click the Navigation menu icon
> Infrastructure
> Storage > Block Storage volumes.
- Select a volume from the list, and click the volume name to go to the volume details page.
- 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
to delete a specific snapshot.
- Select Delete. If the snapshot is actively restoring a volume, the delete operation does not work.
- 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.
- Go to the list of all snapshots. In the IBM Cloud console, go to the menu
> Infrastructure
> Storage > Snapshots.
- Click the row to select the snapshot that you want to delete.
- From the Actions menu
, select Delete all for volume.
- 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.
- Go to the list of all Block Storage for VPC volumes. In the IBM Cloud console, go to the menu
> Infrastructure
> Storage > Block Storage volumes.
- Select a volume from the list and click the volume name to go to the volume details page.
- Click Snapshots to see a list of snapshots taken of this volume.
- Click Delete all to delete all snapshots for this volume.
- Alternatively, select a single snapshot in the list for deletion and then:
- Click the Actions icon
.
- Select Delete.
- Confirm the deletion.
- Click the Actions icon
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.
-
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 -
Run the
snapshot-deletecommand 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 -
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.
-
List all snapshots.
ibmcloud is snapshots --volume VOLUME [--resource-group-id RESOURCE_GROUP_ID | --resource-group-name RESOURCE_GROUP_NAME | --all-resource-groups] -
Enter the
snapshots-deletecommand and specify the volume ID.ibmcloud is snapshots-delete --volume VOLUME_ID -
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.