Here you will find ideas and code straight from the Software Development Team at SportsEngine. Our focus is on building great software products for the world of youth and amateur sports. We are fortunate to be able to combine our love of sports with our passion for writing code.
The SportsEngine application originated in 2006 as a single Ruby on Rails 1.2 application. Today the SportsEngine Platform is composed of more than 20 applications built on Rails and Node.js, forming a service oriented architecture that is poised to scale for the future.
We found we needed a Windows batch script that could create EBS snapshots for a specific volume and clean up the old ones. This is a gist of the script we ended up using to schedule our daily snapshots.
Before you can even successfully run this script, you need to install the Amazon EC2 Command Line Tools
Important steps to note:
%EC2_HOME%\binget added to your
PATHsystem variable. It's easy to miss those steps.
us-east-1, make sure you follow Task 5: Set the Region (Optional)
Once you are able to successfully run
ec2-describe-snapshots from a cmd prompt, you should be set to schedule this script.
AWS_HOMEvariable to a directory that can hold temporary text files that the script needs to create.
AWS_VOLUMEvariable to the volume-id of the volume that you want to snapshot.
AWS_SNAPSHOT_KEEPvariable to the number of snapshots you want to keep.
Just open up Scheduled Tasks, set the Action to be the location of the batch file, ex:
Once scheduled, the batch script will take care of creating snapshots and rotating out old ones. Here's the script in its entirety: