मैं अपने ईसी 2 उदाहरणों के लिए एक साधारण पायथन बैकअप स्क्रिप्ट बनाने की कोशिश कर रहा हूं। इस स्क्रिप्ट का उद्देश्य वर्तमान मशीन के दैनिक/साप्ताहिक स्नैपशॉट बनाना है (this question on ServerFault देखें)। मैं EC2 एपीआई के लिए boto अजगर पैकेज का उपयोग कर रहा है, और किसी दिए गए उदाहरण से (ElasticFox की "छवि बनाएँ" कार्रवाई की तरह)मैं बोटो का उपयोग कर चल रहे इंस्टेंस से ईसी 2 छवि कैसे बना सकता हूं?
# This script will look up all your running EC2 images, find the current one, and back it up by creating an AMI
# Configuration
accessKeyId = "..."
accessKeySecret = "..."
target = "..."
def resolveIp(target):
import socket
ip = repr(socket.gethostbyname_ex(target)[2][0])
return ip
def find_target(target, connection) :
ip = resolveIp(target)
print "Finding instance for " + target + " (IP " + ip + ")"
reservations = connection.get_all_instances();
for reservation in reservations:
instances = reservation.instances
if len(instances) != 1:
print "Skipping reservation " + reservation
continue
instance = instances[0]
instanceIp = resolveIp(instance.dns_name)
if instanceIp == ip:
return instance
raise Exception("Can't find instance with IP " + ip)
from boto.ec2.connection import EC2Connection
print "Connecting to EC2"
conn = EC2Connection(accessKeyId, accessKeySecret)
print "Connected to EC2"
instance = find_target(target, conn)
print "Backing up instance '{}'".format(instance)
# Now, I'd like to create a new image out of this instance
# Can you help?
(इसके अलावा an issue on the boto project page के रूप में रिपोर्ट एक EBS एएमआई बनाना चाहेंगे, क्योंकि मैं नहीं था ' मेलिंग सूची नहीं मिलती)