diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2016-04-16 17:40:58 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2016-04-16 17:40:58 -0700 |
commit | 2b617d9413c73bc657c41abbcd7f72444549df7a (patch) | |
tree | 88be55f07a6bf2cbb551deadac1f90e6c52f72cc /bin/boto-empty-bucket | |
parent | fc04851684f31c7246bf562a224168f9fdab64aa (diff) | |
download | dotfiles-2b617d9413c73bc657c41abbcd7f72444549df7a.tar.gz |
emptys3* scripts take an argument & renamed
Diffstat (limited to 'bin/boto-empty-bucket')
-rwxr-xr-x | bin/boto-empty-bucket | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/bin/boto-empty-bucket b/bin/boto-empty-bucket new file mode 100755 index 00000000..45ff931c --- /dev/null +++ b/bin/boto-empty-bucket @@ -0,0 +1,21 @@ +#!/usr/bin/env python + +"""boto-empty-bucket -- delete all versions from an s3 bucket""" + +import boto +import sys + +def main(): + """Main procedure""" + + bucket = sys.argv[1] + + connection = boto.connect_s3() + bucket = connection.get_bucket(bucket) + + for version in bucket.list_versions(): + print "deleting", version.name, "version", version.version_id + bucket.delete_key(version.name, version_id=version.version_id) + +if __name__ == "__main__": + main() |