Fast way of deleting non-empty Google bucket?

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

    Use this to set an appropriate lifecycle rule. e.g. wait for a day.

    https://cloud.google.com/storage/docs/gsutil/commands/lifecycle
    

    Example (Read carefully before copy paste)

    gsutil lifecycle set [LIFECYCLE_CONFIG_FILE] gs://[BUCKET_NAME]
    

    Example (Read carefully before copy paste)

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

    Then delete the bucket.

    This will delete the data asynchronously, so you don't have to keep some background job running on your end.

提交回复
热议问题