lifecycle - Get or set lifecycle configuration for a bucket

lifecycle - Get or set lifecycle configuration for a bucket

Synopsis

gsutil lifecycle get url
gsutil lifecycle set config-json-file url...

Description

The lifecycle command can be used to get or set lifecycle management policies for the given bucket(s). This command is supported for buckets only, not objects. For more information on object lifecycle management, please see the Cloud Storage docs.

The lifecycle command has two sub-commands:

Get

Gets the lifecycle configuration for a given bucket. You can get the lifecycle configuration for only one bucket at a time. The output can be redirected into a file, edited and then updated via the set sub-command.

Set

Sets the lifecycle configuration on one or more buckets. The config-json-file specified on the command line should be a path to a local file containing the lifecycle configuration JSON document.

Examples

The following lifecycle configuration JSON document specifies that all objects in this bucket that are more than 365 days old will be deleted automatically:

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

The following (empty) lifecycle configuration JSON document removes all lifecycle configuration for a bucket:

{}
本頁內容對您是否有任何幫助?請提供意見:

傳送您對下列選項的寶貴意見...

這個網頁
Cloud Storage
需要協助嗎?請前往我們的支援網頁