Skip to main content

Delete S3 buckets fast

· 2 min read
Stephan Hochdörfer
Head of IT Business Operations

It's time for some spring-cleaning. I decided to delete a large S3 bucket we used for some backups on IONOS Cloud.

My naive approach was to try to manually delete the bucket via the IONOS Cloud Web Ui. Somehow, that did not work properly, so I went on and tried the same with an S3 GUI client.

It took quite a long time to delete a single directory out of the S3 bucket. To understand what's going on, I went to dive deeper into how 3S and S3 clients work. As it turns out, deleting a directory will recursively delete file by file, each triggered by its own web request.

Is there a quicker way to delete an S3 bucket? Let's think outside the box. Instead of deleting the S3 bucket, why not try to synchronize an empty local directory with it? The result should be the same. That was my line of thinking.

I used rclone for this experiment. After configuring rclone to be able to talk to the IONOS S3 bucket, I created an empty local directory ./empty and ran the following command:

rclone sync ./empty ionos-fra:my-bucket --progress --fast-list

And guess what? After roughly 6 minutes, the empty directory was synced to S3, and that bucket was empty. Now, I could finally remove the bucket. Job done.