Skip to content

Instantly share code, notes, and snippets.

@peterkodermac
Created April 28, 2020 07:33
Show Gist options
  • Save peterkodermac/d9f5bbeeb8b70cfae8a3abb3d4e67799 to your computer and use it in GitHub Desktop.
Save peterkodermac/d9f5bbeeb8b70cfae8a3abb3d4e67799 to your computer and use it in GitHub Desktop.
Digital ocean create snapshots - backups
import digitalocean
import random
api_key = 'REPLACE_API'
manager = digitalocean.Manager(token=api_key)
my_droplets = manager.get_all_droplets()
zmayDroplet=my_droplets[0]
zmayDroplet.take_snapshot('snapshot-'+str(random.randint(1,10000))) #this makes a snapshot
print "snapshot made"
snapshots=manager.get_all_snapshots()
if len(snapshots)>1:
destroySnapshot=digitalocean.Snapshot.get_object(api_key, snapshots[0].id)
destroySnapshot.destroy()
else:
print "no snapshots to delete"
@GOPIPACHA
Copy link

Ok thanks no worries

@GOPIPACHA
Copy link

GOPIPACHA commented May 9, 2020

Hey Hi ,

Hiw are you are doing

I just wanted to know can we create a snapshot basesd on the tag name or any otherway apart from position of droplet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment