Skip to content

Instantly share code, notes, and snippets.

/delete.py

Created Sep 20, 2016
Embed
What would you like to do?
#!/usr/bin/env python
import boto
BUCKET_NAME = "bucket-name"
DELETE_DATE = "2016-09-15"
counter = 0
bucket = boto.connect_s3().get_bucket(BUCKET_NAME)
for v in bucket.list_versions():
if (isinstance(v, boto.s3.deletemarker.DeleteMarker) and
v.is_latest and
DELETE_DATE in v.last_modified):
counter += 1
bucket.delete_key(v.name, version_id=v.version_id)
print counter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.