How to backup your entire server from EC2 to S3

How to backup your entire server from EC2 to S3

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!

6 responses on “How to backup your entire server from EC2 to S3

  1. Kesh June 25, 2009 at 6:01 am

    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.

  2. admin June 25, 2009 at 9:20 am

    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)

  3. Muthu August 7, 2009 at 3:27 am

    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 !

  4. sprite March 26, 2011 at 7:11 pm

    i have mount all my file on ec2 instanche thath have on /dev/sda2

    when i launch my backup with ec2-bundle-vol the image include sda2 ?

    During backup show on video “EXCLUDING FOLDER”… ??!?!?!?

  5. sprite March 26, 2011 at 7:12 pm

    also…..

    The backup include backup files ?!?!?

Leave a Reply

Related Posts

    No Releated Posts