Question

Paid Snapshots & Batch removing snapshots

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!


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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

  1. 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.

The for loop asb was helpful for my needs.

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.