Bucket object lifecycle configuration
Written by
Object Storage lets you manage lifecycles for objects in buckets. To upload the lifecycle configuration to Object Storage, you need to create an XML document as described in this section. You can obtain a document in this format by downloading an existing configuration.
General configuration format:
<LifecycleConfiguration>
<Rule>
<ID>Rule description</ID>
<Status>{Enabled|Disabled}</Status>
<Filter>
<Prefix>key_ prefix</Prefix>
</Filter>
<Transition>
<StorageClass>Storage class ID</StorageClass>
<!-- <Date> or <Days> -->
</Transition>
<Expiration>
<!-- <Date> or <Days> -->
<!-- <ExpiredObjectDeleteMarker> -->
</Expiration>
<NoncurrentVersionTransition>
<StorageClass>Storage class ID</StorageClass>
<NoncurrentDays>Migrating versions that are older than the specified number of days</NoncurrentDays>
</NoncurrentVersionTransition>
<NoncurrentVersionExpiration>
<NoncurrentDays>Deleting versions that are older than the specified number of days</NoncurrentDays>
</NoncurrentVersionExpiration>
<AbortIncompleteMultipartUpload>
<DaysAfterInitiation>Deleting uploads that were not completed within the specified number of days</DaysAfterInitiation>
</AbortIncompleteMultipartUpload>
...
</Rule>
<Rule>
...
</Rule>
...
</LifecycleConfiguration>
A configuration may contain up to 1000 rules.
Elements
Element | Description |
---|---|
AbortIncompleteMultipartUpload |
Rule for deleting uploads not completed within the specified number of days. Contains the DaysAfterInitiation element that sets when the rule applies.Path: LifecycleConfiguration\Rule\AbortIncompleteMultipartUpload\DaysAfterInitiation . |
Date |
Date of rule execution. Format: ISO 8601, for example, YYYY-MM-DD . Time is always 00:00 UTC.Path: LifecycleConfiguration\Rule\Expiration\Date . |
Days |
Rule execution interval. This is defined by the number of days since the object was uploaded. Path: LifecycleConfiguration\Rule\Expiration\Days . |
Expiration |
Rule for deleting an object from Object Storage. Contains the Days or Date element that sets the action expiry.It may also contain ExpiredObjectDeleteMarker : An expired object delete marker that indicates whether Object Storage will remove the delete marker if there aren't any non-current versions.Path: LifecycleConfiguration\Rule\Expiration . |
Filter |
Object filter. Contains no more than one Prefix element. If an empty <Filter></Filter> filter is set, the rule applies to all objects in a bucket.Path: LifecycleConfiguration\Rule\Filter . |
ID |
Unique rule ID. Custom text up to 255 characters long, such as "Delete in 20 days". An optional parameter that you can use to search for a rule in a configuration. If no ID is specified, Object Storage generates one automatically. Path: LifecycleConfiguration\Rule\ID . |
LifecycleConfiguration |
Root element of an XML document. It may contain up to 1000 Rule elements.Path: LifecycleConfiguration . |
Prefix |
Key prefix. You can use it to filter objects that meet the rule. Examples of prefixes for the key some/long/object/key : some , some/ , some/lo .Filters can only contain one prefix. Path: LifecycleConfiguration\Rule\Filter\Prefix . |
Rule |
Rule description. Objects that meet the rule are set by the Filter element. Actions on objects are defined by the Transition and Expiration elements. There can be multiple actions of each type.Path: LifecycleConfiguration\Rule . |
Status |
Rule status. You can activate a rule by setting <Status>Enabled</Status> for it, or disable it by setting <Status>Disabled</Status> .Path: LifecycleConfiguration\Rule\Status . |
StorageClass |
Storage class of an object. Path: LifecycleConfiguration\Rule\Transition\StorageClass . |
Transition |
The rule to change the storage class of an object. It contains the StorageClass element, which defines the target storage class and the Date or Days element, which sets when the action expires.You can only move objects from standard to cold storage. Path: LifecycleConfiguration\Rule\Transition\ . |
NoncurrentVersionTransition |
The rule to change the storage class for non-current object versions. This rule only applies to non-current versions of an object rather than the entire object. Contains the StorageClass element that sets the target storage class and the NoncurrentDays element that sets the action expiry.You can only move objects from standard to cold storage. Path: LifecycleConfiguration\Rule\NoncurrentVersionTransition . |
NoncurrentVersionExpiration |
Rule for deleting non-current object versions from Object Storage. This rule only applies to non-current versions of an object rather than the entire object. Contains the NoncurrentDays element that sets the action expiry.Path: LifecycleConfiguration\Rule\NoncurrentVersionExpiration . |
Example
The rule below applies to all objects uploaded to the bucket as follows:
- They are moved to cold storage 30 days after being uploaded to Object Storage.
- They are deleted from Object Storage 365 days after being uploaded.
- Deleting incomplete uploads from Object Storage 5 days after the start of the object upload.
<LifecycleConfiguration>
<Rule>
<ID>Move and then delete</ID>
<Status>Enabled</Status>
<Filter>
<Prefix></Prefix>
</Filter>
<Transition>
<StorageClass>COLD</StorageClass>
<Days>30</Days>
</Transition>
<Expiration>
<Days>365</Days>
</Expiration>
<AbortIncompleteMultipartUpload>
<DaysAfterInitiation>5</DaysAfterInitiation>
</AbortIncompleteMultipartUpload>
</Rule>
</LifecycleConfiguration>