Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
Software Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Lifecycle Configuration Examples

Updated on 2024-10-24 GMT+08:00

If you use APIs or SDKs, refer to the XML example. If you use the OBS Console or OBS Browser+, refer to the screenshot.

Specifying a Rule with a Single Filter Condition

Example 1: Applying a lifecycle rule to all objects in a bucket

To apply the rule to all objects in the bucket, leave the prefix blank. Objects will be transitioned to the Archive storage class 100 days after creation.

XML:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
<LifecycleConfiguration>
    <Rule>
        <ID>sample-rule</ID>  
        <Prefix></Prefix>
        <Status>Enabled</Status>
        <Transition>   
            <Days>100</Days>   
            <StorageClass>COLD</StorageClass>   
        </Transition>  
    </Rule>
</LifecycleConfiguration>

Example 2: Specifying a filter by object name prefix

The following lifecycle rule specifies prefix texta/ as the filter. It applies to objects with the texta/ prefix, such as texta/file1.txt and texta/file2.txt.

This rule specifies two actions: transitioning objects to the Infrequent Access storage class 90 days after creation and deleting objects 120 days after creation.

XML:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
<LifecycleConfiguration>
    <Rule>
        <ID>sample-rule</ID>  
        <Status>Enabled</Status>
        <Prefix>texta/</Prefix>
        <Transition>   
            <Days>90</Days>   
            <StorageClass>WARM</StorageClass>   
        </Transition>  
        <Expiration>
            <Days>120</Days>
        </Expiration>
    </Rule>
</LifecycleConfiguration>

Example 3: Specifying a filter by object name prefix and deleting the specified objects that was last modified before the specified date

The following lifecycle rule specifies prefix texta/ as the filter. It applies to objects with the texta/ prefix, such as texta/file1.txt and texta/file2.txt.

This rule specifies one action: deleting objects that were last modified before May 30, 2024.

XML:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<LifecycleConfiguration>
    <Rule>
        <ID>sample-rule</ID>  
        <Status>Enabled</Status>
        <Prefix>texta/</Prefix>
        <Expiration>
            <Date>2024-05-30T00:00:00.000Z</Date>
        </Expiration>
    </Rule>
</LifecycleConfiguration>

Example 4: Specifying a filter by object name prefix and transitioning the specified objects that was last modified before the specified date

The following lifecycle rule specifies prefix texta/ as the filter. It applies to objects with the texta/ prefix, such as texta/file1.txt and texta/file2.txt.

This rule specifies one action: transitioning objects that were last modified before May 30, 2024 to the Archive storage class.

XML:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
<LifecycleConfiguration>
    <Rule>
        <ID>sample-rule</ID>  
        <Status>Enabled</Status>
        <Prefix>texta/</Prefix>
        <Transition>   
            <Date>2024-05-30T00:00:00.000Z</Date>   
            <StorageClass>COLD</StorageClass>   
        </Transition>  
    </Rule>
</LifecycleConfiguration>

Specifying Multiple Rules

If you want objects to have different lifecycle actions, you can specify multiple rules. The following lifecycle configuration has two rules:

  1. Rule 1 applies to objects with the texta/ prefix. It directs OBS to transition objects to the Archive storage class 120 days after creation and to delete them 360 days after creation.
  2. Rule 2 applies to objects with the textb/ prefix. It directs OBS to transition objects to the Infrequent Access storage class 90 days after creation and to delete them 120 days after creation.

XML:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<LifecycleConfiguration>
    <Rule>
        <ID>sample-rule1</ID>  
        <Prefix>texta/</Prefix>
        <Status>Enabled</Status>
        <Transition>   
            <Days>120</Days>   
            <StorageClass>COLD</StorageClass>   
        </Transition>  
        <Expiration>
            <Days>360</Days>
        </Expiration>
    </Rule>
    <Rule>
        <ID>sample-rule2</ID>  
        <Prefix>textb/</Prefix>
        <Status>Enabled</Status>
        <Transition>   
            <Days>90</Days>   
            <StorageClass>WARM</StorageClass>   
        </Transition>  
        <Expiration>
            <Days>120</Days>
        </Expiration>
    </Rule>
</LifecycleConfiguration>

Specifying Multiple Rules with Overlapping Filter Conditions

NOTE:

For details about overlapping prefixes and conflicting actions, see Overlapping Lifecycle Rules.

Example 1: Overlapping prefixes (no conflict)

  • Rules: Rule 1 specifies an empty filter (indicating all objects in the bucket). It lets OBS delete all objects 120 days after creation. Rule 2 specifies the typea/ prefix (indicating objects with the typea/ prefix). It lets OBS transition objects to the Archive storage class 90 days after creation.
  • Result: There are no conflicting lifecycle actions. Objects with the typea/ prefix are transitioned to the Archive storage class 90 days after creation and then deleted 120 days after creation.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
<LifecycleConfiguration>
    <Rule>
        <ID>sample-rule1</ID>  
        <Prefix></Prefix>
        <Status>Enabled</Status>
        <Expiration>
            <Days>120</Days>
        </Expiration>
    </Rule>
    <Rule>
        <ID>sample-rule2</ID>  
        <Prefix>typea/</Prefix>
        <Status>Enabled</Status>
        <Transition>   
            <Days>90</Days>   
            <StorageClass>COLD</StorageClass>   
        </Transition>  
    </Rule>
</LifecycleConfiguration>

Example 2: Overlapping prefixes resulting in conflicting lifecycle actions

  • Rules: Rule 1 specifies an empty filter (indicating all objects in the bucket). It lets OBS delete all objects 90 days after creation. Rule 2 specifies the typea/ prefix (indicating objects with the typea/ prefix). It lets OBS transition objects to the Archive storage class 120 days after creation.
  • Result: The lifecycle actions conflict. Such configuration is not allowed.
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    <LifecycleConfiguration>
        <Rule>
            <ID>sample-rule1</ID>  
            <Prefix></Prefix>
            <Status>Enabled</Status>
            <Expiration>
                <Days>90</Days>
            </Expiration>
        </Rule>
        <Rule>
            <ID>sample-rule2</ID>  
            <Prefix>typea/</Prefix>
            <Status>Enabled</Status>
            <Transition>   
                <Days>120</Days>   
                <StorageClass>COLD</StorageClass>   
            </Transition>  
        </Rule>
    </LifecycleConfiguration>
    

Deleting Fragments

The following lifecycle rule specifies prefix texta/ as the filter. It applies to objects with the texta/ prefix, such as texta/file1.txt and texta/file2.txt. This rule lets OBS delete object fragments 10 days after generation.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
</LifecycleConfiguration>
   <Rule>
        <ID>sample-rule</ID>
        <Prefix>texta/</Prefix>
        <Status>Enabled</Status>
        <AbortIncompleteMultipartUpload>
            <DaysAfterInitiation>10</DaysAfterInitiation>
        </AbortIncompleteMultipartUpload>
    </Rule>
</LifecycleConfiguration>

Specifying a Lifecycle Rule for a Versioning-Enabled/Suspended Bucket

Example 1: Periodically transitioning and deleting historical object versions

The following lifecycle rule specifies prefix prefix1/ as the filter. It applies to objects with the prefix1/ prefix, such as prefix1/file1.txt and prefix1/file2.txt.

This rule specifies two lifecycle actions: transitioning historical object versions to the Archive storage class 20 days after generation and deleting them 30 days after generation.

Example 2: Removing expired delete markers

The following lifecycle rule specifies prefix prefix1/ as the filter. It applies to objects with the prefix1/ prefix, such as prefix1/file1.txt and prefix1/file2.txt.

If all versions of an object with the prefix1/ prefix have been deleted and only one expired delete marker remains, this rule lets OBS remove this expired delete marker.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
</LifecycleConfiguration>
   <Rule>
        <ID>sample-rule</ID>
        <Prefix>prefix1/</Prefix>
        <Status>Enabled</Status>
        <Expiration>
            <ExpiredObjectDeleteMarker>true</ExpiredObjectDeleteMarker>
        </Expiration>
    </Rule>
</LifecycleConfiguration>

Disabling a Lifecycle Rule

The following configuration disables a lifecycle rule. This rule applies to objects with the texta/ prefix and transitions objects to the Archive storage class 100 days after creation.

XML:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
<LifecycleConfiguration>
    <Rule>
        <ID>sample-rule</ID>  
        <Status>Disabled</Status>
        <Prefix>texta/</Prefix>
        <Transition>   
            <Days>100</Days>   
            <StorageClass>COLD</StorageClass>   
        </Transition>  
    </Rule>
</LifecycleConfiguration>

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback