Fast way of deleting non-empty Google bucket?

前端 未结 7 1676
一整个雨季
一整个雨季 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:25

    This deserves to be summarized and pointed out.

    Deleting with gsutil rm is slow if you have LOTS (terabytes) of data

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

    However, you can specify the expiration for the bucket and let the GCS do the work for you. Create a fast-delete.json policy:

    {
       "rule":[
          {
             "action":{
                "type":"Delete"
             },
             "condition":{
                "age":0
             }
          }
       ]
    }
    

    then apply

    gsutil lifecycle set fast-delete.json gs://MY-BUCKET
    

    Thanks, @jterrace and @Janosch

提交回复
热议问题