Overview

About

Rotate EC2 snapshots.

Requirements

  • Python
  • Boto >= 2.4.0

Usage

ec2-rotate-snapshots.py [options] <regular expression>

Command-line options

--version show program's version number and exit
-h, --help show this help message and exit
-k KEY AWS access key id, uses environment variable by default
-s SECRET AWS secret access key, uses environment variable by default
-r REGION Region. Default: us-east-1
-a AGE Older than these many days
-t TAG Match this tag and, optionally, content
-T TIMEFRAME Timeframe selector. Example: 15:30-15:45
-d Actually delete instead of printing the matches
-q Only print errors

Examples

Remove all snapshots older than 5 days:

ec2-rotate-snapshots.py -a 5 -d ".*"

Remove all snapshots older than 7 days with a description starting with "backup":

ec2-rotate-snapshots.py -a 5 -d "^backup"

Remove all snapshots older than 7 days that has the tag "backup":

ec2-rotate-snapshots.py -a 5 -t backup -d ".*"