Snapshot EBS Devices Attached to EC2 Instances
The script depends on boto. It has been tested on RHEL 6.5 on AWS successfully.
$ git clone https://github.com/shawnsi/ec2snapshot.git
$ cd ec2snapshot
$ pip install .
The github pages site for this project hosts a yum repository.
$ curl -o /etc/yum.repos.d/ec2snapshot.repo https://raw.githubusercontent.com/shawnsi/ec2snapshot/0.0.3/ec2snapshot.repo
$ yum install ec2snapshot
This script is dead simple. It expects to lookup the local instance information via boto.utils.get_instance_metadata. The AWS credentials should be provided by IAM roles for EC2.
Run the script to snapshot all attached EBS volumes.
$ ec2snapshot
The builtin boto.ec2.trip_snapshots method is used to cleanup snapshots. This is executed at the end of each run and will affect all snapshots associated with the AWS account.
Assign an IAM Role to the EC2 instance with these permissions at a minimum.
"Effect": "Allow",
"Action": [
"ec2:CreateSnapshot",
"ec2:CreateTags",
"ec2:DeleteSnapshot",
"ec2:DescribeInstances",
"ec2:DescribeSnapshots",
"ec2:DescribeTags",
"ec2:DescribeVolumes"
],
"Resource": [
"*"
]