1
0
mirror of https://github.com/minio/docs.git synced 2025-07-30 07:03:26 +03:00
Files
docs/source/reference/minio-mc/mc-retention-set.rst
Andrea Longo 1f8ce6dec2 Add reference page for mc du (#783)
Create a new reference page for `mc du` and link it in the list of `mc`
commands.

Staged:

http://192.241.195.202:9000/staging/DOCS-764/linux/html/reference/minio-mc/mc-du.html

Includes drive-by fixes to make the _Optional_ notations appear in a
more consistent manner. (Including several otherwise unrelated pages.)
There's more opportunistic fixes here than I might normally do in the
same PR, but seemed better to get it over with.

Fixes https://github.com/minio/docs/issues/764

---------

Co-authored-by: Ravind Kumar <ravind@min.io>
2023-03-30 13:36:41 -06:00

11 KiB

mc retention set

minio

Table of Contents

mc retention set

Syntax

The mc retention set command configures the Write-Once Read-Many (WORM) locking <minio-object-locking> settings for an object or object(s) in a bucket. You can also set the default object lock settings for a bucket, where all objects without explicit object lock settings inherit the bucket default.

To lock an object under legal hold <minio-object-locking-legalhold>, use mc legalhold set.

mc retention set requires that the specified bucket has object locking enabled. You can only enable object locking at bucket creation. See mc mb --with-lock for documentation on creating buckets with object locking enabled.

EXAMPLE

The following command sets a default 30 day GOVERNANCE <minio-object-locking-governance> object lock on the mydata bucket on the myminio MinIO deployment:

mc retention set --default GOVERNANCE "30d" myminio/mydata

SYNTAX

The command has the following syntax:

mc [GLOBALFLAGS] retention set                         \
                 [--bypass]                            \
                 [--default]                           \
                 [--recursive]                         \
                 [--rewind "string"]                   \
                 [--versions]                          \
                 [--version-id "string"]*              \
                 MODE                                  \
                 "VALIDITY"                            \
                 ALIAS

mc retention set --version-id is mutually exclusive with multiple other parameters. See the reference documentation for more information.

Parameters

MODE

Sets the locking mode for the ~mc retention set ALIAS. Specify one of the following supported values:

  • governance
  • compliance

See the AWS S3 documentation on Object Lock Overview <object-lock-overview.html> for more information on the supported modes.

Requires specifying ~mc retention set VALIDITY.

VALIDITY

The duration which objects remain in the specified ~mc retention set MODE after creation.

  • For days, specify a string formatted as Nd. For example,

    30d for 30 days after object creation.

  • For years, specify a string formatted as Ny. For example,

    1y for 1 year after object creation.

ALIAS

Required

The full path to the object or objects for which to set object lock configuration. Specify the alias <alias> for the MinIO or S3-compatible service and the full path to bucket. For example:

mc retention set play/mybucket/object.txt MODE VALIDITY
  • If the ALIAS specifies a bucket or bucket prefix, include ~mc retention set --recursive to apply the object lock settings to the bucket contents.
  • mc retention set by default applies to only the latest object version. Use ~mc retention set --version-id or ~mc retention set --versions to apply the object lock settings to a specific version or to all versions of the object respectively.
--bypass

Optional Allows a user with the s3:BypassGovernanceRetention permission to modify the object. Requires the governance retention ~mc retention set MODE

--default

Optional Sets the default object lock settings for the bucket specified to ~mc retention set ALIAS using the ~mc retention set MODE and ~mc retention set VALIDITY. Any objects created in the bucket inherit the default object lock settings unless explicitly overriden using mc retention set.

If specifying ~mc retention set --default, mc retention set ignores all other flags.

--recursive

Recursively applies the object lock settings to all objects in the specified ~mc retention set ALIAS path.

Mutually exclusive with ~mc retention set --version-id.

--rewind
--version-id

Mutually exclusive with any of the following flags:

  • ~mc retention set --versions
  • ~mc retention set --rewind
  • ~mc retention set --recursive
--versions

Use ~mc retention set --versions and ~mc retention set --rewind together to apply the retention settings to all object versions that existed at a specific point-in-time.

Global Flags

Examples

Set Default Bucket Retention Settings

Use mc retention set with the ~mc retention set --recursive and ~mc retention set --default to set the default bucket retention settings.

mc retention set  --recursive --default MODE DURATION ALIAS/PATH
  • Replace MODE <mc retention set MODE> with the retention mode to enable. MinIO supports the AWS S3 retention modes governance and compliance.
  • Replace DURATION <mc retention set VALIDITY> with the duration which the object lock should remain in effect. For example, to set a retention period of 30 days, specify 30d.
  • Replace ALIAS <mc retention set ALIAS> with the alias <mc alias> of a configured S3-compatible host.
  • Replace PATH <mc retention set ALIAS> with the path to the bucket.

Set Object Lock Configuration for Versioned Object

Specific Version

Use mc retention set with ~mc retention set --version-id to apply the retention settings to a specific object version:

mc retention set --version-id VERSION MODE DURATION ALIAS/PATH
  • Replace VERSION <mc retention set --version-id> with the version of the object.
  • Replace MODE <mc retention set MODE> with the retention mode to enable. MinIO supports the AWS S3 retention modes governance and compliance.
  • Replace DURATION <mc retention set VALIDITY> with the duration which the object lock should remain in effect. For example, to set a retention period of 30 days, specify 30d.
  • Replace ALIAS <mc retention set ALIAS> with the alias <mc alias> of a configured S3-compatible host.
  • Replace PATH <mc retention set ALIAS> with the path to the object.

All Versions

Use mc retention set with ~mc retention set --versions to apply the retention settings to a specific object version:

mc retention set --versions  MODE DURATION ALIAS/PATH
  • Replace MODE <mc retention set MODE> with the retention mode to enable. MinIO supports the AWS S3 retention modes governance and compliance.
  • Replace DURATION <mc retention set VALIDITY> with the duration which the object lock should remain in effect. For example, to set a retention period of 30 days, specify 30d.
  • Replace ALIAS <mc retention set ALIAS> with the alias <mc alias> of a configured S3-compatible host.
  • Replace PATH <mc retention set ALIAS> with the path to the object.

Behavior

Retention of Object Versions

For buckets with versioning enabled <mc version>, mc retention set by default operates on the latest version of the target object or object(s). mc retention set includes specific options that when explicitly specified direct the command to operate on either a specific object version or all versions of an object:

Specific Object Version

To direct mc retention set to operate on a specific version of an object, include the --version-id argument:

  • mc retention set --version-id
  • mc retention set --version-id
  • mc retention set --version-id

All Object Versions

To direct mc retention set to operate on all versions of an object, include the --versions argument:

  • mc retention set --versions
  • mc retention set --versions
  • mc retention set --versions

Locking an object prevents any modification or deletion of that object, similar to the COMPLIANCE <mc retention set MODE> object locking mode. Objects can have simultaneous retention-based locks and legal hold locks.

The legal hold lock overrides any retention locking, such that an object under legal hold remains locked even if the retention period expires. Setting, modifying, or clearing retention settings for an object under legal hold has no effect until the legal hold either expires or is explicitly disabled.

For more information on object legal holds, see mc legalhold.

S3 Compatibility