Updated on 2024-04-16 GMT+08:00

Configuring a Lifecycle Rule

You can configure a lifecycle rule for a bucket or a set of objects to:

  • Expire objects and then delete them.

Procedure

  1. In the bucket list, click the bucket you want to operate to go to the Objects page.
  2. In the navigation pane, choose Overview.
  3. In the Basic Configurations area, click Lifecycle Rules. The Lifecycle Rules page is displayed.

    Alternatively, you can choose Basic Configurations > Lifecycle Rules in the navigation pane.

  4. Click Create.
  5. Configure a lifecycle rule.

    Basic Information:
    • Status:

      Select Enable to enable the lifecycle rule.

    • Rule Name:

      It identifies a lifecycle rule. A rule name can contain a maximum of 255 characters.

    • Prefix: It is optional.
      • If this field is configured, objects with the specified prefix will be managed by the lifecycle rule. The prefix cannot start with a slash (/) or contain two consecutive slashes (//), and cannot contain the following special characters: \:*?"<>|
      • If this field is not configured, all objects in the bucket will be managed by the lifecycle rule.
    • If the specified prefix overlaps with the prefix of an existing lifecycle rule, OBS regards these two rules as one and forbids you to configure the one you are configuring. For example, if there is already a rule with prefix abc in OBS, you cannot configure another rule whose prefix starts with abc.
    • If there is already a lifecycle rule based on an object prefix, you are not allowed to configure another rule that is applied to the entire bucket.
    • If a lifecycle rule has been configured for the entire bucket, no more rules that apply to object name prefix can be added.

    Current Version or Historical Version:

    • If Versioning was ever enabled for a bucket, both Current Version and Historical Version can be configured.

      The Historical Version appears only when the versioning is enabled or suspended for the bucket.

    • Current Version and Historical Version are two concepts for versioning. If versioning is enabled for a bucket, uploading objects with the same name to the bucket creates different object versions. The last uploaded object is called the current version, while those previously uploaded are called historical versions.
    • You can configure either the Current Version or Historical Version, or both of them.
    • Delete Objects After (Days): After this number of days since the last update, objects meeting certain conditions will be expired and then deleted.
    For example, on January 7, 2015, you saved the following files in OBS:
    • log/test1.log
    • log/test2.log
    • doc/example.doc
    • doc/good.txt
    On January 10, 2015, you saved another four files:
    • log/clientlog.log
    • log/serverlog.log
    • doc/work.doc
    • doc/travel.txt

    On January 10, 2015, you set the objects prefixed with log to expire one day later. You might encounter the following situations:

    • Objects log/test1.log and log/test2.log uploaded on January 7, 2015 might be deleted after the last system scan. The deletion could happen on January 10, 2015 or January 11, 2015, depending on the time of the last system scan.
    • Objects log/clientlog.log and log/serverlog.log uploaded on January 10, 2015 might be deleted on January 11, 2015 or January 12, 2015, depending on whether they have been stored for over one day (since their last update) when the system scan happened.

    In theory, it takes 24 hours at most to execute a lifecycle rule. Because OBS calculates the lifecycle of an object from the next 00:00 (UTC time) after the object is uploaded, there may be a delay in deleting expired objects. Generally, the delay does not exceed 48 hours. If you make changes to an existing lifecycle rule, the rule will take effect again.

  6. Click OK to complete the lifecycle rule configuration.

Follow-up Procedure

You can click Enable, Edit, or Disable in the Operation column of a lifecycle rule to enable, edit, or disable the rule.

If you want to delete more than one lifecycle rule at a time, select them and click Delete above the list.