Earlier I posted a way to cleanup snapshots. I’ve had a few emails asking how I automated the creation. Here is a quick command line (Linux) to automate the creation of the snapshots. Make sure you have your environment setup and the latest version of the EC2 Tools API installed and in the PATH. You can place this command as a cron entry, or simply run it from the command line.
for a in $(ec2-describe-volumes |grep -Ev "ATTACHMENT" |cut -f2);do ec2-create-snapshot $a; done;
All this is doing is grabbing the volume ID’s from the ec2-describe-volumes output – removing the extraneous information, and executing the ec2-create-snapshot command on each volume. The good thing about this is that it doesn’t have to be modified as you add new volumes. Please see my earlier posting on snapshot cleanup to have a full solution from creation to cleanup.
Quick and easy.


{ 2 } Comments
a better tool to use especially if you’re running mysql on any of your instances is the ec2-consistent-backup program. It will freeze your drive and mysql for a couple seconds so you get a clean snapshot that you can safely reload mysql from. Otherwise the binary files can often be corrupted because of database reads/writes happening during the snapshot process.
http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1663
Very true; thanks for the input Doug.
Post a Comment