mc ilm add

Adds an object lifecycle management rule to a bucket.

Syntax

Run mc ilm add to add an object lifecycle rule.

mc ilm add [COMMAND FLAGS] TARGET

FLAGS:
 --prefix value                                    object prefix
 --tags value                                      format '<key1>=<value1>&<key2>=<value2>&<key3>=<value3>', multiple values allowed for multiple key/value pairs
 --size-lt value                                   objects with size less than this value (in bytes) will be selected for the lifecycle action
 --size-gt value                                   objects with size greater than this value (in bytes) will be selected for the lifecycle action
 --expire-date value                               format 'YYYY-MM-DD' the date of expiration
 --expire-days value                                the number of days to expiration
 --noncurrent-expire-days value                     the number of days to remove noncurrent versions (default: 0)
 --noncurrent-expire-newer value                    number of newer non-current object versions to retain (default: 0)
 --expire-delete-marker remove                      delete markers with no parallel versions
 --abort-incomplete-multipart-upload-days value     abort any incomplete multipart uploads that have not aborted in number of days (default: 0)
 --disable                                          disable the rule
 --enable                                           enable the rule
 --json                                             enable JSON lines formatted output
 --debug                                             enable debug output
 --insecure                                          disable SSL certificate verification
 --help, -h                                          show help

Parameters

Parameter Description
--prefix Restrict the management rule to a specific object prefix. Prefix can also be specified as part of the alias/ bucket/prefix. This is an optional parameter.
--tags One or more ampersand(&) delimited key-value pairs describing the object tags to use for filtering objects to which the lifecycle configuration rule applies. This is an optional parameter.
NOTE
Tags are not populated for delete markers and incomplete multi-part objects that still in progress. The --tags option is mutually exclusive with --expire-delete-marker and abort-incomplete-multipart-upload-days.
--size-lt Select fully uploaded objects smaller than the specified value. Enter the value as a number and a unit, such as 1m for 1 MB. This option is mutually exclusive option with --expire-delete-marker and abort-incomplete-multipart-upload-days. This is an optional parameter. Unit is added as a suffix to the number and indicated as follows: k for KB, m for MB, g for GB, t for TB, ki for kiB, mi for MiB, gi for GiB, ti for TiB.
--size-gt Select fully uploaded objects larger than the specified value qualify for the expiration rule. Enter the value as a number and a unit, such as 5GiB for 5 gibibytes. This option is mutually exclusive option with --expire-delete-marker and abort-incomplete-multipart-upload-days.
--expire-date Indicates at what date the object is to be deleted. Deletes all objects that are eligible for deletion on or before the specified date. This is an optional parameter.
--expire-days The number of days after which the object expires.
--noncurrent-expire-days The number of days to retain a non-current or older object version. The option marks the older object version for deletion after the specified number of days elapse. This is an optional parameter.
--noncurrent-expire-newer The maximum number of non-current object versions to retain, when ordered from newest to oldest. Retains the newest of the number of past versions of a file. After retaining the maximum number of non-current versions, any remaining older or non-current object versions are marked for expiration. Updating the number for this flag only impacts the unmarked versions of objects. Any versions already marked for expiration do not change if you increase the number to retain. For example, if the value for this parameter is 3, the last 3 versions of the object would be retained and the object versions that are older than the last 3 would be marked for deletion/expiry. This is an optional parameter.
--expire-delete-marker This option is used to remove the delete marker.
--abort-incomplete-multipart-upload-days The number of days after which an incomplete multi-part object upload must be aborted.
--disable Use this option to disable the object lifecycle rule.
--enable Use this option to enable the object lifecycle rule.
--help Use this option to display the command help.

Example

Expire all the current versions for objects in bucket bkt1, where the folder name starts with meetingnotes and the current object version is older than 90 days.

CLI
$ mc ilm add --prefix "meetingnotes/" aliasName/bkt1 --expire-days "90"

Expire the current objects in bucket bkt1 with tags“dept=finance” and “priority=high” and size > 50 GB that are more than 90 days old.

CLI
$ mc ilm add aliasName/bkt1 --tags 'dept=finance&priority=high' --size-gt 53,687,091,200 --expire-days 90

Expire current objects created 365 days back and expire objects that became non-current 30 days back. (Current objects are retained for a year but the non-current versions expire after 30 days.)

CLI
$ mc ilm add --prefix "doc/" --expire-days "365" --noncurrent-expire-days "30" aliasName/mybucket

Remove delete markers for objects in bucket bkt1, where the delete marker is the only version of the object that remains

CLI
$ mc ilm add aliasName/bkt1 --expire-delete-marker