Skip to content

Instantly share code, notes, and snippets.

@robballou
Created June 22, 2011 16:36
Show Gist options
  • Save robballou/1040490 to your computer and use it in GitHub Desktop.
Save robballou/1040490 to your computer and use it in GitHub Desktop.
Rotatelib EC2 example
import datetime
import rotatelib
"""
When you call list_archives or remove_items with an ec2snapshots argument, the library
will look in your environment variables for AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
If you do not want to use environment variables, you can pass those in as keyword args
(aws_access_key_id and aws_secret_access_key).
"""
# list all archive items that are older than 5 days
items = rotatelib.list_archives(ec2snapshots=True,
before=datetime.timedelta(5),
startswith=['Web Server Backup', 'DB Server Backup'])
# now remove all the items list_archives returned above
rotatelib.remove_items(items=items, ec2snapshots=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment