Stay organized with collections Save and categorize content based on your preferences.

lifecycle - Get or set lifecycle configuration for a bucket


gsutil lifecycle get gs://<bucket_name>
gsutil lifecycle set <config-json-file> gs://<bucket_name>...


You can use the lifecycle command to get or set lifecycle management policies for a given bucket. This command is supported for buckets only, not objects. For more information, see Object Lifecycle Management.

The lifecycle command has two sub-commands:


Gets the lifecycle management configuration for a given bucket. You can get the lifecycle management configuration for only one bucket at a time. To update the configuration, you can redirect the output of the get command into a file, edit the file, and then set it on the bucket using the set sub-command.


Sets the lifecycle management 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.


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

      "action": {"type": "Delete"},
      "condition": {"age": 365}

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