Backing up ec2 with ec2-consistent-snapshot


I have updated below to support not just name but arbitrary tags. here is my pull request:

If you have time, do test it. 

Recently I deployed a web app on AWS ec2 and we needed a way to backup daily. After a few search I found this script ec2-consistent-snapshot. This script works great but I had problem using it in instance with IAM role (I did not wanted to store credentials in machine). Problem was actually with the dependency of the script that is libnet-amazon-ec2-perl package, I was using ubuntu 13.10 and it had 0.23 version of that package. as 0.23 did not support the use of IAM roles I had to install 0.24 of the package. Below is the comamnd that I used to install latest version of libnet-amazon-ec2-perl.

sudo dpkg -i libnet-amazon-ec2-perl_0.24-1_all.deb

After installing this latest version of dependency everything worked great with IAM role and I was able to create snapshots with the command:

ec2-consistent-snapshot --use-iam-role --mysql --description "Website at $(date +'%Y-%m-%d %H:%M:%S')" vol-id

I used this command to execute daily from cronjob. What I now wanted do was to Tag the snapshot with Name so that Name field was not blank in Aws console. So I forked the project and edited the script to work with tagging to tag Name field. This is my forked repo You can use it like this:

ec2-consistent-snapshot —use-iam-role —mysql —description “Website at $(date +’%Y-%m-%d %H:%M:%S’)” —name “snapshot Name” vol-id