How to backup your entire server from EC2 to S3

Posted by admin | Posted in Cloud Computing | Posted on 07-04-2009

4

Today I will describe in short how to create an AMI instance of EC2 and than upload it to S3 server. All you need to have is running instance of EC2 server (I’m using Debian) with EC2 tools preinstalled.
First of all, make sure that you don’t have any unnecessary files on your server filesystem which you don’t need to bundle in an image as it will only slow the process down and make your costs of storing backup images higher.
Once you are sure that your instance is fine and EC2 tools are in place you have to transfer your private key file and certificate file to the server. Lets put the files under /root directory.
If all is set up correctly, first of all, we create and image by running:

ec2-bundle-vol -d /mnt -k /root/PrivateKey.pem  --cert /root/Certificate.pem  -u 012345678901

The number after the -u flag is your Amazon account ID which you can find on the AWS website once logged in.
Running above command will take a bit and will create a number of files under /mnt directory.
Once we have the files and manifest ready (all happens auto-magically) we can start transferring the image onto S3 account.
In order to transfer your image on S3 you would have to create a bucket there first, for this you can use famous firefox plugin (S3 Organizer) or do it using Affirma’s library (previous post).

ec2-upload-bundle -b yourbucketname00404042009 -m /mnt/image.manifest.xml -a your_s3_access_key -s your_s3_secret_access_key

If for some reason you encouter any problems during upload but your bundling went ok, you can retry the upload using –retry flag:

ec2-upload-bundle -b yourbucketname00404042009 -m /mnt/image.manifest.xml -a your_s3_access_key -s your_s3_secret_access_key  --retry

Happy bundling!

StumbleuponDelicious

Comments (4)

[...] Start’ listing a few example AMIs, select your own instances created earlier (see my post on backup up the whole EC2 image), or simply search for already created community AMIs. We will choose the last option and search [...]

How do we restore it ? Let’s say current instance corrupted or lost.
We need to launch new instance with saved instance (that uploaded into S3). Please advise.

You would have to register it using ec2 tools:

ec2-register <your-s3-bucket> /image.manifest.xml

and then launch it using this command:

ec2-run-instances <ami-identifier>

or Amazon AWS Console (http://www.softwarepassion.com/?p=164)

Is it ok to remove the files in /mnt after I backup the files to my bucket. Thanks for the article. It was simple and works !

Write a comment