Monday, April 25, 2011

Automate EBS snapshots with Ebs2s3 on Amazon EC2

I've spent a while looking for a simple way to schedule regular snapshots of EBS volumes for Amazon EC2-based production environments. The snapshot feature is really useful: it allows you to take regular delta backups of your EBS volumes and save them it S3, which can then be used to rebuild the volume in the event of a system failure.  The solutions I've come across, though, seem to mostly consist of running scripts via cron, which isn't intuitive or easy to manage.  So I've put together a little rails app to do the job: Ebs2s3

Ebs2s3 allows you to flexibly schedule backups of your volumes using standard cron syntax, and to specify the number of backups to retain.  Some screenshots:

The login page

Displaying current jobs 

Showing an individual job

More details (including installation instructions) can be found on the project page, here


  1. Guys,

    Daily snapshot is possible with a simple shell script.



    #Setting parameters to run ec2 commands
    export JAVA_HOME=/path/to/jdk
    export EC2_HOME=/path/tp/ec2-api-tools
    export PATH=$PATH:$EC2_HOME/bin
    export EC2_CERT=/path/to/cert-file
    export EC2_PRIVATE_KEY=/path/to/privatekey file
    export PATH=$PATH:$JAVA_HOME/bin:/EC2_HOME/bin

    #Specifying the certificates
    MY_KEY=/path/to/privatekey file

    #Instance & EBS Volume details

    DAY="$(date +"%d-%m-%Y")"
    #creating the snapshots
    for volume in $(echo $VOLUME_LIST); do
    ec2-create-snapshot -C $MY_CERT -K $MY_KEY $volume -d snapshot-description-$DAY


    Edit this script accordingly & put this in your cron, snapshot will be taken care of.

  2. @Jayaraj K

    Thanks for the script! Works great, though I eliminated the second certificate specification (MY_CERT and MY_KEY) - any reason why that is necessary?

    Now, I will just eventually need to end a snapshot deletion script so too many don't build up.