All Products
Search
Document Center

:Archive files

更新時間:Jan 30, 2024

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.

    Note

    CSG supports Standard, IA, and Archive OSS buckets.

  • An NFS share is created.

    Note
    • CSG 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.

Note

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.

  1. Log on to the OSS console.

  2. In the left-side navigation pane, click Buckets. On the Buckets page, click the name of the bucket.

  3. In the left-side navigation tree, choose Data Management > Lifecycle.

  4. (Optional) To create a lifecycle rule based on last access time, turn on Enable Access Tracking on the Lifecycle page.

  5. On the Lifecycle page, click Create Rule.

  6. 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.

    Note

    If 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.

    Note

    For more information about billing rules for objects in the new storage class, see Lifecycle rules based on the last modified time.

  7. Click OK.

    Important
    • Lifecycle 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

  1. Log on to your host that runs the Linux operating system.

  2. Download the gateway archive management tool: sgw_archive_util.

  3. Run the following command to grant the permission to run the archive management tool:

    sudo chmod a+x sgw_archive_util
  4. 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.

  5. 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.