1
0
mirror of https://github.com/minio/docs.git synced 2025-07-28 19:42:10 +03:00
Files
docs/source/reference/minio-mc/mc-mv.rst
Daryl White abee6a35d6 Updates for two Oct 2023 mc releases (#1066)
Updates for October 2023 MinIO Client releases
    
- Adds output sample for `mc support top locks`
- Adds `mc idp ldap accesskey` and subcommands
    
Closes #1056
    
- Adds environment variables for most global flags
- Adds --retry flag to mc mirror
- Adds --bucket-bandwidth flag to mc admin replicate update
    
Partially addresses #1045

- Removes unsupported `--noncurrent-transition-newer` flags from
commands.
2023-11-10 14:05:07 -05:00

12 KiB

mc mv

minio

Table of Contents

mc mv

Syntax

The mc mv command moves an object from source to the target, such as between MinIO deployments or between buckets on the same MinIO deployment. mc mv also supports moving objects between a local filesystem and MinIO.

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

EXAMPLE

The following command moves objects from the mydata bucket to the archive bucket on the myminio MinIO deployment:

mc mv --recursive myminio/mydata myminio/archive

SYNTAX

The command has the following syntax:

mc [GLOBALFLAGS] mv         \
[--attr "string"]           \
[--continue]                \
[--disable-multipart]       \
[--encrypt "string"]        \
[--encrypt-key "string"]    \
[--limit-download string]   \
[--limit-upload string]     \
[--newer-than "string"]     \
[--older-than "string"]     \
[--preserve]                \
[--recursive]               \
[--storage-class "string"]  \
SOURCE [SOURCE...]          \
TARGET

Parameters

SOURCE

The object or objects to move.

For moving an object from a MinIO bucket, specify the alias <alias> and the full path to the object(s) (e.g. bucket and path to objects). For example:

mc mv play/mybucket/object.txt play/myotherbucket/object.txt

For moving an object from a local filesystem, specify the full path to that object. For example:

mc mv ~/mydata/object.txt play/mybucket/object.txt

Specify multiple SOURCE paths to move multiple objects to the specified ~mc mv TARGET. mc rm treats the last specified alias or filesystem path as the TARGET. For example:

mc mv ~/mydata/object.txt play/mydata/otherobject.txt myminio/mydata

If you specify a directory or bucket to ~mc mv SOURCE, you must also specify ~mc mv --recursive to recursively move the contents of that directory. If you omit the ~mc mv --recursive argument, ~mc mv only moves objects in the top level of the specified directory or bucket.

TARGET

The full path to the bucket to which the command moves the object(s) at the specified ~mc mv SOURCE. Specify the alias <alias> of a configured S3 service as the prefix to the ~mc mv TARGET path.

For moving an object from MinIO, specify the alias <alias> and hte full path to the object(s) (e.g. bucket and path to objects). For example:

mc mv play/mybucket/object.txt play/myotherbucket/object.txt

For moving an object from a local filesystem, specify the full path to that object. For example:

mc mv ~/mydata/object.txt play/mybucket/object.txt

The TARGET object name can differ from the SOURCE to "rename" the object as part of the move operation.

If running mc mv with the ~mc mv --recursive option, mc mv treats the TARGET as the bucket prefix for all objects at the SOURCE.

--attr

Add custom metadata for the object. Specify key-value pairs as KEY=VALUE\;. For example, --attr key1=value1\;key2=value2\;key3=value3.

--continue, c

Create or resume a move session.

--disable-multipart

Disables the multipart upload feature.

Multipart upload breaks an object into a set of separate parts. Each part uploads individually and in any order. If any individual part upload fails, MinIO retries that part without affecting the other parts. After upload completes, the parts combine to restore the original object.

MinIO recommends using multipart upload for any object larger than 100 MB. For more information on multipart upload, refer to the Amazon S3 documentation <mpuoverview.html>

--encrypt

Encrypt or decrypt objects using server-side encryption with server-managed keys. Specify key-value pairs as KEY=VALUE.

  • Each KEY represents a bucket or object.
  • Each VALUE represents the data key to use for encrypting

    object(s).

Enclose the entire list of key-value pairs passed to ~mc mv --encrypt in double-quotes ".

~mc mv --encrypt can use the MC_ENCRYPT environment variable for retrieving a list of encryption key-value pairs as an alternative to specifying them on the command line.

--encrypt-key

Encrypt or decrypt objects using server-side encryption with client-specified keys. Specify key-value pairs as KEY=VALUE.

  • Each KEY represents a bucket or object.
  • Each VALUE represents the data key to use for encrypting

    object(s).

Enclose the entire list of key-value pairs passed to ~mc mv --encrypt-key in double quotes ".

~mc mv --encrypt-key can use the MC_ENCRYPT_KEY environment variable for retrieving a list of encryption key-value pairs as an alternative to specifying them on the command line.

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

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

--preserve, a

Preserve file system attributes and bucket policy rules of the ~mc mv SOURCE directories, buckets, and objects on the ~mc mv TARGET bucket(s).

--recursive, r

Recursively move the contents of each bucket or directory ~mc mv SOURCE to the ~mc mv TARGET bucket.

--storage-class

Set the storage class for the new object(s) on the ~mc mv TARGET.

See the Amazon documentation on Storage Classes <AmazonS3/latest/dev/storage-class-intro.html> for more information on S3 storage classses.

Global Flags

Examples

Move Files from Filesystem to S3-Compatible Host

mc mv [--recursive] FILEPATH ALIAS/PATH
  • Replace FILEPATH <mc mv SOURCE> with the full file path to the file to move.

    If specifying the path to a directory, include the ~mc mv --recursive flag.

    mc mv removes the files from the source after successfully moving it to the destination.

  • Replace ALIAS <mc mv TARGET> with the alias <mc alias> of a configured S3-compatible host.

  • Replace PATH <mc mv TARGET> with the destination bucket.

Move a File from Filesystem to S3-Compatible Host with Custom Metadata

Use mc mv with the ~mc mv --attr option to set custom attributes on file(s).

mc mv --attr "ATTRIBUTES" FILEPATH ALIAS/PATH
  • Replace FILEPATH <mc mv SOURCE> with the full file path to the file to move. mc mv removes the file from the source after successfully moving it to the destination.
  • Replace ALIAS <mc mv TARGET> with the alias <mc alias> of a configured S3-compatible host.
  • Replace PATH <mc mv TARGET> with the destination bucket.
  • Replace ATTRIBUTES <mc mv --attr> with one or more comma-separated key-value pairs KEY=VALUE. Each pair represents one attribute key and value.

Move Bucket Between S3-Compatible Services

mc mv --recursive SRCALIAS/SRCPATH TGTALIAS/TGTPATH
  • Replace SRCALIAS <mc mv SOURCE> with the alias <mc alias> of a configured S3-compatible host.
  • Replace SRCPATH <mc mv SOURCE> with the path to the bucket. mc mv removes the bucket and its contents from the source after successfully moving it to the destination.
  • Replace TGTALIAS <mc mv TARGET> with the alias <mc alias> of a configured S3-compatible host.
  • Replace TGTPATH <mc mv TARGET> with the path to the bucket.

Move File to S3-Compatible Host with Specific Storage Class

Use mc mv with the ~mc mv --storage-class option to set the storage class on the destination S3-compatible host.

mc mv --storage-class CLASS FILEPATH ALIAS/PATH
  • Replace CLASS <mc mv --storage-class> with the storage class to associate to the files.

  • Replace FILEPATH <mc mv SOURCE> with the full file path to the file to move. mc mv removes the file from the source after successfully moving it to the destination.

  • Replace ALIAS <mc mv TARGET> with the alias <mc alias> of a configured S3-compatible host.

  • Replace PATH <mc mv TARGET> with the destination bucket.

  • Replace ATTRIBUTES <mc mv --attr> with one or more comma-separated key-value pairs KEY=VALUE. Each pair represents one attribute key and value.

    mc mv --storage-class REDUCED_REDUNDANCY myobject.txt play/mybucket

Behavior

Object Names on Move

MinIO uses the ~mc mv SOURCE object name when moving the object to the ~mc mv TARGET if no explicit target object name is specified.

You can specify a different object name for the ~mc mv TARGET with the same object path to "rename" an object. For example:

mc mv play/mybucket/object.txt play/mybucket/myobject.txt

For recursive move operations (mc mv --recursive), MinIO treats the TARGET path as a prefix for objects on the SOURCE.

Checksum Verification

mc mv verifies all move operations to object storage using MD5SUM checksums.

Resume Move Operations

Use mc mv --continue to resume an interrupted or failed move operation from the point of failure.

MinIO Trims Empty Prefixes on Object Removal

S3 Compatibility