All Products
Search
Document Center

Object Storage Service:Extend the retention period of objects in a bucket

Last Updated:Aug 01, 2024

Extends the retention period of objects in a bucket

Usage notes

  • To extend the retention period of objects in a bucket, you must have the oss:ExtendBucketWorm permission. For more information, see Attach a custom policy to a RAM user.

  • By default, a time-based policy is in the InProgress state after the policy is created for a bucket. The policy remains in this state for 24 hours. Within the 24 hours, the retention policy protects the data in the bucket.

    • In the 24-hour window after the retention policy is enabled: If the retention policy is not locked, the bucket owner and authorized users can delete this policy. If the retention policy is locked, the policy cannot be deleted and the retention period specified by the retention policy can only be extended.

    • 24 hours after the retention policy is enabled: If the retention policy is not locked, the policy becomes invalid.

  • If a bucket contains objects that are within the protection period, you cannot delete the bucket or its retention policy. If a bucket is deleted, the retention policy of the bucket is also deleted. Only the bucket owner can delete a bucket when the bucket is empty.

Command syntax

 ossutil api extend-bucket-worm --bucket value --worm-id value --extend-worm-configuration value [flags]

Parameter

Type

Description

--bucket

string

The name of the bucket.

--extend-worm-configuration

string

The container that stores retention policy configurations.

--worm-id

string

The ID of the retention policy.

--extend-worm-configuration

The --extend-worm-configuration option supports XML and JSON formats. If the value of the option contains the "file://" prefix, ossutil reads configurations from the specified file.

  • XML format:

    <ExtendWormConfiguration>
      <RetentionPeriodInDays>integer</RetentionPeriodInDays>
    </ExtendWormConfiguration>
  • JSON format:

    {
      "RetentionPeriodInDays": integer
    }
Note

For more information, see Command-line options.

Examples

Extend the retention period of the objects protected by the "123" retention policy to 366 days.

  • Use an XML configuration file (extend-worm-configuration.xml in this example)

    <?xml version="1.0" encoding="UTF-8"?>
    <ExtendWormConfiguration>
      <RetentionPeriodInDays>366</RetentionPeriodInDays>
    </ExtendWormConfiguration>

    Sample command:

    ossutil api extend-bucket-worm --bucket examplebucket --worm-id 123 --extend-worm-configuration file://extend-worm-configuration.xml
  • Use a JSON configuration file (extend-worm-configuration.json in this example)

    {
            "RetentionPeriodInDays": "366"
    }

    Sample command:

    ossutil api extend-bucket-worm --bucket examplebucket --worm-id 123 --extend-worm-configuration file://extend-worm-configuration.json
  • Use JSON parameters in the command line

    ossutil api extend-bucket-worm --bucket examplebucket --worm-id 123 --extend-worm-configuration " "{\"RetentionPeriodInDays\":\"366\"}""