Created
April 28, 2020 07:33
-
-
Save peterkodermac/d9f5bbeeb8b70cfae8a3abb3d4e67799 to your computer and use it in GitHub Desktop.
Digital ocean create snapshots - backups
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?