This topic describes how to configure lifecycle rules for an Object Storage Service (OSS) bucket and configure automated file archiving to automatically archive files on a file gateway in Cloud Storage Gateway (CSG).
Prerequisites
A Standard bucket or Infrequent Access (IA) bucket is created. For more information, see Create buckets.
NoteCSG supports Standard, IA, and Archive OSS buckets.
An NFS share is created.
NoteCSG automatically archives files only in NFS shares on a file gateway. When you create the share, set the Protocol parameter to NFS.
When you create the share, set the User Mapping parameter to none.
When you create the share, set the Support Archive parameter to Yes.
For more information about how to create a share for a file gateway deployed in Alibaba Cloud, see Create a share.
For more information about how to create a share for a file gateway deployed on premises, see Manage NFS shares.
Background information
CSG V1.0.44 and later versions can automatically archive files on file gateways to OSS buckets.
You can directly use a file gateway to automatically archive and restore files that are in an associated Standard or IA OSS bucket, and query the archive information. You do not need to use the OSS console to manage the lifecycle of an archived file.
To automate file archiving, you must configure lifecycle rules for the OSS bucket in the OSS console first. You do not need to set lifecycle rules if you only need to restore files or query the archiving information.
Step 1: Configure lifecycle rules
You can configure lifecycle rules to change the storage class of one or more objects in an OSS bucket.
Log on to the OSS console.
In the left-side navigation pane, click Buckets. On the Buckets page, click the name of the bucket.
In the left-side navigation tree, choose
.(Optional) To create a lifecycle rule based on last access time, turn on Enable Access Tracking on the Lifecycle page.
On the Lifecycle page, click Create Rule.
In the Create Rule panel, configure the following parameters. For more information about how to configure other parameters, see Configure lifecycle rules to convert the storage classes of objects.
Parameter
Description
Status
Select Enabled.
Applied To
Select Whole Bucket to apply the rule to all objects in the bucket.
NoteIf you select Whole Bucket, you can create only one lifecycle rule for the bucket.
Tag
Turn on Tag and specify tags to apply the rule to objects that have the tags.
Set Key to AutoArchive.
Set Value to enabled.
Object Lifecycle
Specify an object expiration policy. Valid values: Validity Period (Days), Expiration Date, and Disabled. If you select Disabled, the configurations of Object Lifecycle do not take effect.
Lifecycle-based Rules
Configure a rule that moves specified objects into the Archive storage class.
For example, if you configure a lifecycle rule based on last access time to move the specified object into Archive 30 days after last access time, the specified object that was last accessed on September 1, 2021 would be moved into the Archive storage class on October 1, 2021.
NoteFor more information about billing rules for objects in the new storage class, see Lifecycle rules based on the last modified time.
Click OK.
ImportantLifecycle rules immediately take effect after they are created. Make sure that the rules are configured based on your business requirements when you create them.
For more information about lifecycle rules, see Lifecycle rules based on the last modified time.
Step 2: Create an archive management configuration
Log on to your host that runs the Linux operating system.
Download the gateway archive management tool: sgw_archive_util.
Run the following command to grant the permission to run the archive management tool:
sudo chmod a+x sgw_archive_util
Run the following command to enable the archive management tool to automatically archive files:
sgw_archive_util –a /path/file
/path/file indicates the absolute path of the file. Replace it with the actual file path.
Run the following command to verify the archiving result:
ossutil object-tagging --method get oss://file-wanqp/0816/0.txt
oss://file-wanqp/0816/0.txt indicates the path of the archive file in the OSS bucket. Replace it with the actual file path.
In this example, the validity period is set to one day in Step 1: Configure lifecycle rules.
If the following information appears, the file is archived.
What to do next
You can run the following command to use the archive management tool to automatically restore an archived file:
sgw_archive_util -r /path/file
/path/file indicates the absolute path of the file. Replace it with the actual file path.
You can run the following command to use the archive management tool to query the archive information of a file:
sgw_archive_util -q /path/file
/path/file indicates the absolute path of the file. Replace it with the actual file path.