A quick way to automate AWS EC2 Snapshots
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.

