Created
March 19, 2014 12:41
-
-
Save pmoranga/9640867 to your computer and use it in GitHub Desktop.
Create EC2 snapshot from all volumes connected in the VM itself.
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
#!/usr/bin/python | |
from boto.ec2.connection import EC2Connection | |
from boto.utils import get_instance_metadata | |
from datetime import datetime | |
import sys | |
conn = EC2Connection('AUTH_KEY', 'SECRET_KEY') | |
description = 'Created by crontab at ' + datetime.today().isoformat(' ') | |
m = get_instance_metadata() | |
volumes = [v for v in conn.get_all_volumes() if v.attach_data.instance_id == m['instance-id']] | |
for v in volumes : | |
snapshot = conn.create_snapshot( v.id ,description) | |
print "Snapshot of %s triggered" % v.id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment