Question

Paid Snapshots & Batch removing snapshots

Posted August 16, 2016 2.6k views
Billing Control Panels

Hi,

I just got a mail that Snapshots is going to be paid. I’ve got multiple snapshots spread accross 2 accounts (one for each company) and I want to batch remove some old ones, otherwise this is going to be pretty expensive over here :) I was wondering if that’s possible? Thanks!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

4 answers

Our command line client, doctl would make deleting multiple snapshots from your account quite simple. To list all of your images, use:

  • doctl compute image list-user

This allows you to retrieve their image IDs. Using the IDs, you could write a small script to delete in bulk:

#!/bin/bash

for i in 123456 789012; do
    doctl compute image delete "$i"
done

If you wanted to delete all the snapshots on your account, you could do something like:

#!/bin/bash

doctl compute image list-user -o json | jq -c '.[] | select(.type == "snapshot") | .id' | while read i; do
    doctl compute image delete "$i"
done

Of course, our API also supports deleting images. There are libraries in a number of different languages as well.

by Marko Mudrinić
DigitalOcean's web based control panel provides a convenient, point-and-click interface for managing Droplets. There are many times, however, when a command-line tool may be a preferable alternative. doctl, the official DigitalOcean command-line client, leverages the DigitalOcean API to provide access to most account and Droplet features.

You can open your browser console and paste this command:

document.querySelectorAll('.dropdown-view--delete button').forEach(function(button,i){if(i) button.click();});

This will delete all snapshots from the current page except the very first one.

For people that don’t use the API this is a big problem. I think DO should make this feature available from their control panel or at least be able to do this when a Support Ticket is raised.

Unfortunately I raised a ticket and was told that DO will not do this on my behalf and I would need to delete each one manually. That’s going to take quite a bit of time.

There is a feature request here but I doubt it’ll be available in time for the start of the Snapshot billing:
https://digitalocean.uservoice.com/forums/136585-digitalocean/suggestions/15681810-bulk-delete-snapshots

Cheers

Nick

The for loop asb was helpful for my needs.

Submit an Answer