How To Create A New AWS Instance From A Snapshot
Be sure to create regular snapshots of your running instances. If you lose an instance, recover quickly with this procedure. I suggest that you use Elastic IP addresses to make the migration DNS-free.
STEP 1: First, setup your environment properly
1 2 3 4 5 6 |
export EC2_HOME='/opt/aws/apitools/ec2' # Make sure you use the API tools, not the AMI tools export EC2_BIN=$EC2_HOME/bin export EC2_PRIVATE_KEY=/path/to/keys/pk-{Your Private Key ID Here}.pem export EC2_CERT=/path/to/keys/cert-{Your Private Key ID Here}.pem export PATH=$PATH:$EC2_BIN export JAVA_HOME=/usr/java/latest |
STEP 2: Create an AMI linked to the snapshot
% ec2-register -n YOUR-AMI-NAME -d "Your Description Here" --root-device-name /dev/sda1 -b "/dev/sda1=snap-XXXXXXXX" -a x86_64 --kernel aki-427d952
(where XXXXXXXX is the ID of your snapshot…)
This command outputs the new AMI ID:
IMAGE ami-264b8a1c
STEP 3: Start the new instance using the just-created AMI
% ec2run ami-264b8a1c -b "/dev/sda1=snap-XXXXXXXX:10:true" -g Your-Security-Group -t t1.micro -k AWSKeyPair
Which outputs the new instance information…
RESERVATION r-91305ffe 510579120428 Inbound-Relay
INSTANCE i-b97a28d8 ami-264b8a1c pending AWSKeyPair 0 t1.micro 2011-08-16T23:05:37+0000 us-east-1b aki-427d952b monitoring-disabled ebs paravirtual xen
Leave Your Comment
All fields marked with "*" are required.