Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fast way of deleting non-empty Google bucket?

Tags:

Is this my only option or is there a faster way?

# Delete contents in bucket (takes a long time on large bucket) gsutil -m rm -r gs://my-bucket/*  # Remove bucket gsutil rb gs://my-bucket/ 
like image 590
fredrik Avatar asked Apr 24 '15 06:04

fredrik


People also ask

How do you delete a bucket?

In the Buckets list, select the option next to the name of the bucket that you want to delete, and then choose Delete at the top of the page. On the Delete bucket page, confirm that you want to delete the bucket by entering the bucket name into the text field, and then choose Delete bucket.

How do I delete files from the cloud storage?

Open the iCloud Drive folder and tap Recently Deleted. Select the folders or files that you want to delete. Tap Delete.


1 Answers

Buckets are required to be empty before they're deleted. So before you can delete a bucket, you have to delete all of the objects it contains.

You can do this with gsutil rm -r (documentation). Just don't pass the * wildcard and it will delete the bucket itself after it has deleted all of the objects.

gsutil -m rm -r gs://my-bucket 

Google Cloud Storage bucket deletes can't succeed until the bucket listing returns 0 objects. If objects remain, you can get a Bucket Not Empty error (or in the UI's case 'Bucket Not Ready') when trying to delete the bucket.

gsutil has built-in retry logic to delete both buckets and objects.

like image 135
Travis Hobrla Avatar answered Sep 23 '22 05:09

Travis Hobrla