New Options In ec2-expire-snapshots v0.11

The ec2-expire-snapshots program can be used to expire EBS snapshots in Amazon EC2 on a regular schedule that you define. It can be used as a companion to ec2-consistent-snapshot or independently.

There have been two recent submissions to the code from the community that provide new command line options in the latest version (v0.11) of ec2-expire-snapshots.

  1. Wayne Robinson discovered that EC2 sometimes limits the rate at which you can delete snapshots, and submitted code for a new --delete-delay option that tells ec2-expire-snapshots to pause for N seconds between each EBS snapshot deletion.

  2. Anthony Tonns uses EC2’s new feature to copy EBS snapshots from one region to another for redundancy, and found that Amazon does not associate snapshots from the same EBS volume in the source region with the same source volume in the target region. Anthony came up with the idea of putting the source volume id in a tag and submitted code for a new --volume-id-in-tag option that lets you specify the tag name.

Thanks also to varunwy for submitting a patch a while back to clean up some dependencies in the package installation.

On Ubuntu, you can install ec2-expire-snapshots from the Alestic PPA using:

sudo add-apt-repository -y ppa:alestic sudo apt-get update sudo apt-get install -y ec2-expire-snapshots

This example expires EBS snapshots for a volume, preserving the first daily snapshot for the last week, and and the first snapshot each month for the last year. There is also an implicit saving of the most recent snapshot:

ec2-expire-snapshots --keep-first-daily 7 --keep-first-monthly 12 vol-1234678

There are many more options and different approaches to expiring snapshots.

Please read the documentation for more details on usage and how to set up your AWS credentials.