快速删除非空Google存储桶的方法? [英] Fast way of deleting non-empty Google bucket?
问题描述
这是我唯一的选择还是有更快的方法?
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/
推荐答案
在删除存储区之前,存储区必须为空.因此,必须先删除存储桶中包含的所有对象,然后才能删除该存储桶.
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.
您可以使用gsutil rm -r
(文档)进行操作.只是不要传递*
通配符,它将在删除所有对象之后删除存储桶本身.
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
在存储桶列表返回0个对象之前,无法成功删除Google Cloud Storage存储桶.如果对象仍然存在,则在尝试删除存储桶时会收到存储桶未空"错误(或在UI情况下为存储桶未就绪").
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
具有内置的重试逻辑,可以删除存储桶和对象.
gsutil
has built-in retry logic to delete both buckets and objects.
这篇关于快速删除非空Google存储桶的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!