There is a good little tool called s3funnel on GitHub for this. I used easy_install to install on my Mac.
easy_install s3funnel |
For the tool to work you have to provide your AWS ACCESS KEY ID and AWS SECRET ACCESS KEY. The easiest is perhaps to set environment variables. You can find the values through the AWS management console, in upper right corner click your account name and select 'Security Credentials'.
export AWS_ACCESS_KEY_ID=<your AWS access key id> export AWS_SECRET_ACCESS_KEY=<your AWS secret access key> |
You can also provide these values on the commandline with the -a and -s options (you must provide both). To first empty and then delete a bucket called 'mybucket' do this in the shell:
s3funnel mybucket list | s3funnel mybucket delete && s3funnel mybucket drop |
To count the objects before deleting them, in case you're curious (I was), do this:
s3funnel mybucket list | wc -l |
s3funnel Tips:
- Use -t option when using s3funnel to use more threads, e.g. -t 10 for ten threads
- Use -v for verbose output. This way you can see the the scripts is actually progressing