Fast way of deleting non-empty Google bucket?

前端 未结 7 1674
一整个雨季
一整个雨季 2021-02-07 02:05

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 bucke         


        
7条回答
  •  花落未央
    2021-02-07 02:28

    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.

提交回复
热议问题