Skip to content

shawnsi/ec2snapshot

Repository files navigation

ec2snapshot

Build Status

Snapshot EBS Devices Attached to EC2 Instances

Requirements

The script depends on boto. It has been tested on RHEL 6.5 on AWS successfully.

Installation

Pip

$ git clone https://github.com/shawnsi/ec2snapshot.git
$ cd ec2snapshot
$ pip install .

Yum

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

Usage

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

Trimming

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.

IAM Role

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": [
  "*"
]

About

Snapshot EBS Devices Attached to EC2 Instances

Resources

License

Stars

Watchers

Forks

Packages

No packages published