1
$aws ec2 create-image --instance-id xxx --name yyy --description "zzzz" --no-reboot 

This created AMI image of EC2 instance but did not created extra attached volume's snapshot !

So is there any method to backup EBS volumes at time of creating image ? or we have to create volume snapshot separately using

$ec2-create-snapshot i-xxxx  
  • does ec2-bundle-vol do what you want? – chicks Aug 18 '15 at 14:23
  • Here is script which will find all instance's id within a specified VPC and will create AMI backup for each instance ! #!/bin/bash #Script to Automate AMI backup echo "----------------------------------\n date \n----------------------------------" aws ec2 describe-instances --filters Name=vpc-id,Values=vpc-xxx | awk '{ print $8 }' | sort -n | grep "i-" > /tmp/instanceid.txt echo "Starting the Daily AMI creation: " #To create AMI of from instance-id – Ashish Karpe Aug 20 '15 at 6:23
  • for i in $(cat /tmp/instanceid.txt); do echo "Creating AMI for Instance id $i ......." echo "instance-date +%d%b%y-$i" > /tmp/aminame.txt aws ec2 create-image --instance-id $i --name "cat /tmp/aminame.txt" --description "This is created by ami-backup.sh" --no-reboot | grep -ir ami | awk '{print $4}' > /tmp/amiID.txt echo "AMI Name is: cat /tmp/aminame.txt\n" done – Ashish Karpe Aug 20 '15 at 6:23
2

Additional EBS volumes will be included within the AMI, I think that the only limitation is that the AMI excludes the volumes mounted under:

/sys
/proc
/dev
/media
/mnt

so just mount your volumes somewhere else and any AMI should include all your volumes as well

  • As AMI are compressed can I know what is the compression ratio ? – Ashish Karpe Aug 20 '15 at 9:43
  • I guess you ask this to know how would it cost to store your AMIs? here is a link that explains it pretty well:n2ws.com/blog/…. Please note that the snapshot mechanism is incremental, which means that each time you snapshot a volume, it will store only the diff between the previous snapshot and the current one. Thus only the first snapshot is "costly", taking additional snapshot costs almost nothing. But anyway, it does not cost a lot to perform AMI – Tom Aug 20 '15 at 10:10
  • i took ami backup with aws ec2 create-image --instance-id $i --name "cat /tmp/aminame.txt" --description "This is created by ami-backup.sh" --no-reboot .....But it created volume snapshoot which was mounted under /mnt which contradicts according to you ... Additional EBS volumes will be included within the AMI, I think that the only limitation is that the AMI excludes the volumes mounted under: /mnt – Ashish Karpe Aug 20 '15 at 11:52
  • it depends if you use an instance store backed instance or an EBS backed instance. In an EBS backed instance, all volumes attached will be included within your AMI. In a instance store, you will have exclusions as stated above – Tom Aug 20 '15 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.