1
0
mirror of https://github.com/minio/docs.git synced 2025-08-06 14:42:56 +03:00
Files
docs/source/reference/minio-mc/mc-rm.rst
Ravind Kumar 76e5e35ab3 DOCS-1191: Updating SSE params, general fixups (#1295)
Closes #1191 

# Summary

Finally getting around to this mc release

- Added docs for enc-c, enc-s3, enc-kms
- Some docs are making assumptions around behavior that needs to be
fixed _first_
- Drive-by linker fixes

Staged: http://192.241.195.202:9000/staging/DOCS-1191/linux/index.html

---------

Co-authored-by: Andrea Longo <feorlen@users.noreply.github.com>
Co-authored-by: Daryl White <53910321+djwfyi@users.noreply.github.com>
2024-08-26 11:54:49 -04:00

12 KiB

mc rm

minio

Table of Contents

mc rm

Syntax

The mc rm command removes objects <minio-object-delete> from a bucket on a MinIO deployment. To completely remove a bucket, use mc rb instead.

You can also use mc rm against the local filesystem to produce similar results to the rm commandline tool.

For more information on how MinIO performs DELETE actions on objects, see minio-object-delete.

Important

mc rm supports removing multiple objects or files in a single command. Consider using the ~mc rm --dry-run option to validate that the operation targets only the desired objects/files.

EXAMPLE

The following command removes multiple objects from the mydata bucket on the myminio MinIO deployment:

mc rm --recursive myminio/mydata

SYNTAX

The command has the following syntax:

mc [GLOBALFLAGS] rm  \
                 [--bypass]               \
                 [--dangerous]            \
                 [--dry-run]              \
                 [--force]*               \
                 [--incomplete]           \
                 [--newer-than "string"]  \
                 [--non-current]          \
                 [--older-than "string"]  \
                 [--recursive]            \
                 [--rewind "string"]      \
                 [--stdin]                \
                 [--version-id "string"]* \
                 [--versions]             \
                 ALIAS [ALIAS ...]

mc rm --force is required by multiple parameters. mc rm --version-id is mutually exclusive with multiple parameters. See the reference documentation for more information.

Parameters

ALIAS

The alias <alias> of a MinIO deployment and the full path to the object to remove. For example:

mc rm play/mybucket/object.txt

You can specify multiple objects on the same or different MinIO deployments. For example:

mc rm play/mybucket/object.txt play/mybucket/otherobject.txt

If specifying the path to a bucket or bucket prefix, you must also specify the ~mc rm --recursive and ~mc rm --force arguments. For example:

mc rm --recursive --force play/mybucket/

mc rm --recursive --force play/mybucket/myprefix/

Consider first running the command with the ~mc rm --dry-run flag to validate the scope of the recursive delete operation.

For removing a file from a local filesystem, specify the full path to that file:

mc rm ~/data/myoldobject.txt
--bypass

Allows removing an object held under GOVERNANCE <minio-object-locking-governance> object locking.

--dangerous

Allows running mc rm when the ~mc rm ALIAS specifies the root (all buckets) on the MinIO deployment.

When combined with ~mc rm --versions, this flag directs mc rm to permanently remove all objects and versions from the ALIAS target.

Consider first running the command with the ~mc rm --dry-run to validate the scope of the site-wide delete operation.

Warning

Running mc rm --dangerous with the ~mc rm --versions flag is irreversible. Exercise all possible due diligence in ensuring the command applies to only the desired ALIAS targets prior to execution.

--dry-run

Outputs the results of a command without actually removing any files. Use this flag to test that your command configuration removes only the objects you wish to remove.

--force

Allows running mc rm with any of the following arguments:

  • ~mc rm --recursive
  • ~mc rm --versions
  • ~mc rm --stdin

--incomplete, I

Remove incomplete uploads for the specified object.

If any ~mc rm ALIAS specifies a bucket, you must also specify ~mc rm --recursive and ~mc rm --force.

--newer-than

Remove object(s) newer than the specified number of days. Specify a string in #d#hh#mm#ss format. For example: --newer-than 1d2hh3mm4ss

Defaults to 0 (all objects).

--non-current

Removes all non-current <minio-bucket-versioning-delete> object versions from the specified ~mc rm ALIAS.

This option has no effect on buckets without versioning <minio-bucket-versioning> enabled.

--older-than

Remove object(s) older than the specified time limit. Specify a string in #d#hh#mm#ss format. For example: --older-than 1d2hh3mm4ss.

Defaults to 0 (all objects).

--recursive, r

Recursively remove the contents of each ~mc rm ALIAS bucket or bucket prefix.

If specifying ~mc rm --recursive, you must also specify ~mc rm --force.

For buckets with versioning <minio-bucket-versioning> enabled, this option by default produces a delete marker for each removed object. Include the ~mc rm --versions flag to recursively remove all objects and object versions from the bucket.

Consider first running the command with the ~mc rm --dry-run flag to validate the scope of the recursive delete operation.

Mutually exclusive with mc rm --version-id

--rewind
--stdin

Read object names or buckets from STDIN.

--versions

Use ~mc rm --versions and ~mc rm --rewind together to remove all object versions which existed at a specific point in time.

--version-id, vid

Mutually exclusive with any of the following flags:

  • ~mc rm --versions
  • ~mc rm --rewind
  • ~mc rm --recursive

Global Flags

Examples

Remove a Single Object

mc rm ALIAS/PATH
  • Replace ALIAS <mc rm ALIAS> with the alias <mc alias> of a configured S3-compatible service.
  • Replace PATH <mc rm ALIAS> with the path to the object.

Recursively Remove a Bucket's Contents

Use mc rm with the ~mc rm --recursive and ~mc rm --force options to recursively remove a bucket's contents.

mc rm --recursive --force ALIAS/PATH
  • Replace ALIAS <mc rm ALIAS> with the alias <mc alias> of a configured S3-compatible service.
  • Replace PATH <mc rm ALIAS> with the path to the bucket.

This operation does not remove the bucket. Use mc rb to remove the bucket along with all contents and associated configurations.

Remove All Incomplete Upload Files for an Object

Use mc rm with the ~mc rm --incomplete option to remove incomplete upload files for an object.

mc rm --incomplete --recursive --force ALIAS/PATH
  • Replace ALIAS <mc rm ALIAS> with the alias <mc alias> of a configured S3-compatible service.
  • Replace PATH <mc rm ALIAS> with the path to the object.

Roll Object Back To Previous Version

Use mc rm with ~mc rm --versions and ~mc rm --newer-than to remove all object versions newer than the specified duration of time. This effectively "rolls back" the object to its state at that time.

Important

Removing specific versions of an object is a destructive action. You cannot restore the deleted object versions.

mc rm ALIAS/PATH --versions --newer-than DURATION
  • Replace ALIAS <mc rm ALIAS> with the alias <mc alias> of a configured S3-compatible service.
  • Replace PATH <mc rm ALIAS> with the path to the object. For example, /mybucket/myobject.
  • Replace DURATION <mc rm --newer-than> with the number of days in the past from the current host time from which the operation begins removing versions of the object. For example, to remove all versions of the object created in the last 30 days, specify "30d".

Behavior

Deleting Bucket Contents

Using mc rm to remove all contents in a bucket does not delete the bucket itself. Any configurations associated to the bucket remain in place, such as default object lock settings <mc retention set --default>.

To completely remove a bucket, use mc rb instead of mc rm.

MinIO Trims Empty Prefixes on Object Removal

Delete Operations in Versioned Buckets

MinIO supports keeping multiple versions <minio-bucket-versioning> of an object in a single bucket. Deleting <minio-bucket-versioning-delete> an object in a versioned bucket results in a special DeleteMarker tombstone that marks an object as deleted while retaining all previous versions of that object.

  • To remove a specific object version from a bucket, use mc rm --version-id
  • To remove all versions of an object from a bucket, use mc rm --versions
  • To remove all non-current versions of an object from a bucket, use mc rm --non-current

mc RELEASE.2023-03-20T17-17-53Z

The output shows the modification time of versioned files. When used with --dry-run, this can help confirm that you selected the correct object(s) for removal.

S3 Compatibility