Welcome to the upcoming version of the MinIO Documentation! The content on this page is under active development and may change at any time. If you can't find what you're looking for, check our legacy documentation. Thank you for your patience.

Automatic Object Expiration

Each procedure on this page creates a new object lifecycle management rule that expires objects on a MinIO bucket. This procedure supports use cases like removing “old” objects after a certain time period or calendar date.

Requirements

Install and Configure mc

This procedure uses mc for performing operations on the MinIO cluster. Install mc on a machine with network access to both source and destination clusters. See the mc Installation Quickstart for instructions on downloading and installing mc.

Use the mc alias command to create an alias for the source MinIO cluster and the destination S3-compatible service. Alias creation requires specifying an access key for a user on the source and destination clusters. The specified users must have permissions for configuring and applying expiry operations.

Required Permissions

MinIO requires the following permissions scoped to the bucket or buckets for which you are creating lifecycle management rules.

MinIO also requires the following administrative permissions on the cluster in which you are creating remote tiers for object transition lifecycle management rules:

For example, the following policy provides permission for configuring object transition lifecycle management rules on any bucket in the cluster:.

{
   "Version": "2012-10-17",
   "Statement": [
      {
            "Action": [
               "admin:SetTier",
               "admin:ListTier"
            ],
            "Effect": "Allow",
            "Sid": "EnableRemoteTierManagement"
      },
      {
            "Action": [
               "s3:PutLifecycleConfiguration",
               "s3:GetLifecycleConfiguration"
            ],
            "Resource": [
                        "arn:aws:s3:::*"
            ],
            "Effect": "Allow",
            "Sid": "EnableLifecycleManagementRules"
      }
   ]
}

Expire Objects after Calendar Date

Use mc ilm add with --expiry-date to expire bucket contents after a specific date.

mc ilm add ALIAS/PATH --expiry-date "DATE"
  • Replace ALIAS with the alias of the S3-compatible host.

  • Replace PATH with the path to the bucket on the S3-compatible host.

  • Replace DATE with the calendar date after which to expire the object. For example, specify “2021-01-01” to expire objects after January 1st, 2021.

Expire Objects after Number of Days

Use mc ilm add with --expiry-days to expire bucket contents a number of days after object creation:

mc ilm add ALIAS/PATH --expiry-days "DAYS"
  • Replace ALIAS with the alias of the S3-compatible host.

  • Replace PATH with the path to the bucket on the S3-compatible host.

  • Replace DATE with the number of days after which to expire the object. For example, specify 30d to expire the object 30 days after creation.

Expire Versioned Objects

Use mc ilm add to expiring noncurrent object versions and object delete markers:

mc ilm add ALIAS/PATH \
   --noncurrentversion-expiration-days NONCURRENT_DAYS \
   --expired-object-delete-marker
  • Replace ALIAS with the alias of the S3-compatible host.

  • Replace PATH with the path to the bucket on the S3-compatible host.

  • Replace NONCURRENT_DAYS with the number of days after which to expire noncurrent object versions. For example, specify 30d to expire a version after it has been noncurrent for at least 30 days.