Backing up ec2 with ec2-consistent-snapshot

Update:

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

https://github.com/alestic/ec2-consistent-snapshot/pull/27

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.

wget http://security.ubuntu.com/ubuntu/pool/universe/libn/libnet-amazon-ec2-perl/libnet-amazon-ec2-perl_0.24-1_all.deb
sudo dpkg -i libnet-amazon-ec2-perl_0.24-1_all.deb

http://askubuntu.com/questions/426177/how-to-update-libnet-amazon-ec2-perl-to-latest-version-in-sausy

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 https://github.com/yalamber/ec2-consistent-snapshot 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