Object Storage Service (OSS) uses the Write Once Read Many (WORM) retention policy to specify the protection period of objects in a bucket. During the protection period, the protected objects cannot be modified or deleted.
- A bucket cannot have both versioning and retention policies configured at the same time. If versioning is enabled for a bucket, you cannot configure retention policies for the bucket. For more information about versioning, see Overview.
- For more information about the retention policy, see Retention policy.
- Log on to the OSS console.
- Click Buckets, and then click the name of the target bucket.
- Choose Retention Policy section, click Configure. . In the
- Click Create Policy. The Create Policy dialog box appears.
- Set Retention Period for the retention policy. Valid values of Retention Period range from one day to 70 years.
- Click OK. After the policy is created, the status indicates IN_PROGRESS. You can click Lock or Delete to lock or delete a policy in the IN_PROGRESS state.
- Click Lock.
- In the message that appears, click OK. Note
- The policy status becomes LOCKED. You cannot delete the policy or shorten the protection period. However, you can click Edit to prolong the protection period.
- During the protection period, data in the bucket is protected. If you attempt to delete
or modify the data, the following error message is displayed:
The file is locked and cannot be operated.
Calculate the expiration time for objects
You can calculate the expiration time by adding the retention period and last update time of objects in buckets. For example, the retention policy for Bucket A specifies the retention period as 10 days. The last update time of an object in the bucket is 12:00 on March 1, 2019. The object expires at 12:01 on March 11, 2019. For more information about the rules of the compliant retention policy, see the "Rules" section in Compliant retention policy.