If you try to delete an S3 bucket while there are still items inside, you’ll get the error message
The bucket you tried to delete is not empty. Please delete all objects and folders in the bucket and try again.
If you have items are in the root folder of a bucket, you have to delete them first. Sounds easy, unless you have millions of object in your bucket! To make matters worse, there is no API to empty a bucket.
You have several options.
- Try to empty the bucket through the web interface: There is no Select All button, and if you try to select too many objects at once you’ll get a Loading… screen which loses your selection. And if your keys contain strings like // or \ the web interface will break.
- Use a client app: CloudBerry Explorer for Amazon S3 or SpaceBlock for Windows are good. Unfortunately, they are not multithreaded so deleting millions of objects can take a long time. Recommended.
- Write some code: delete-s3-bucket.pl written by Jonathan Kamens is extremely helpful. Maxim Veksler’s BucketDestroy Java app has got me out of trouble too. These scripts are your only option if you have keys with control characters in their names.
To avoid this problem in the future, create a folder within your bucket and place all your files there.
Going to test Spaceblock! After hours of clicking "Delete" on folders....
ReplyDeleteI'm migrating form JungleDisk/S3 to Crashplan, but deleting 80 GB is like clicking until the end of your live.
Try this: bucket.delete_keys(bucket.list())
ReplyDelete