Use this guide to understand how to delete from our CLI  snapshots present on a server.

This could be a workaround in situations when GUI is not available as the storage limit occupation was reached, or when a general cleaning is required

Deleting snapshots

There're different ways to delete a snapshot from CLI depending on your necessities. 

Here are some alternatives we provide for most common scenarios

When no date criteria is relevant

When no date criteria is relevant you can delete a number of  snapshots, that are going to be cancelled  whitout a specific order criteria of data or size of the snapshots present on the system.

If the interest is to filter by schedules the snapshots to be deleted. 
There's a possibility to delete a number of snapshot considering only the type of schedule

for example: deleting 100 snapshots from the daily schedule of a specific datastore, or just all the snapshot related to that schedule.

Delete a number of snapshots 

Step 1: Verify how many snapshot are present on the system

  • zfs list -r -t snapshot | wc -l

Step 2:  Delete a number of snapshots without specific criteria

  • zfs list -r -t snapshot | awk '{ print $1 }' | head -n 1000 | xargs -L1 zfs destroy

    In the example above the number is 1000, feel free to modify this as required on your system

Delete snapshots with schedule criteria

To find datastore path, use : zfs list 

Scenario 1: Delete all snapshots of a specific schedule

  • zfs list -r -t snapshot <datastore> | grep weekly |  awk '{ print $1 }' | xargs -L1 zfs destroy

    In this example  the schedule is "weekly", feel free to modify the input with the schedule of your interest

Scenario 2: Delete a number of snapshots of a specific schedule

  • zfs list -r -t snapshot <datastore> | grep weekly |  awk '{ print $1 }' | head -n 100 | xargs -L1 zfs destroy

When date is relevant

in case you're looking to delete an amount of snapshots, or a single snapshot, based on date of creation, follow the bellow steps :

Delete a single snapshot 

To find datastore path, use : zfs list 

Step 1: List the datastore snapshots

  • zfs list -r -t snapshot flash/datastores/vm

    In the above example "vm" is the datastore name

Step 2: Delete the single snapshot of your interest

  • zfs destroy flash/datastores/vm@auto:minute-by-minute-flash--datastores--vm-2021-03-10-17:48

          Remember to be logged as sudoer, otherwise you will get permission error

Delete a selected group of snapshots 

Step 1: List the datastore snapshots

  • zfs list -r -t snapshot flash/datastores/vm

Step 2: Identify the slot of snapshots you're interested to delete, and define which is the first and the last of it

In the above you will see an example of the slot of our interest in red and the first and last snapshot in yellow. Meaning we are looking to delete all the protections for the datastore "VM" between  17:48 and 17:55 of the 10/03/2021

Step 3: Delete

  • To delete gather the entire path of the snapshot you defined as first and collect the path information on the last one from the "@". With this information proceed as follows:

  • zfs destroy flash/datastores/vm@auto:minute-by-minute-flash--datastores--vm-2021-03-10-17:48%auto:minute-by-minute-flash--datastores--vm-2021-03-10-17:55

In case of errors please contact our support team