what's different between "mc cp --recursive" and "mc mirror --overwrite"
Asked Answered
H

3

13

If we want to copy a bucket to another MiniO cluster, should we use "mc cp" or "mc mirror"? I have done some simple experiments and it seems that they are the same.

Thank~!

Hemiplegia answered 2/1, 2020 at 4:5 Comment(0)
T
3

Short answer

Yes, mc cp --recursive SOURCE TARGET and mc mirror --overwrite SOURCE TARGET will have the same effect (to the best of my experience as of 2022-01).

  • mc cp allows for fine-tuned options for single files (but can bulk copy using --recursive)
  • mc mirror is focussed on bulk copying and can create buckets

Looking at the Minio client guide, there are several differences between the mc mirror and the mc cp commands, although the result of running them can be the same.

The answer to which one should you use depends on your requirements, and both options may be acceptable for you.

Details

The command signature differ: mc cp allows for multiple sources while mc mirror only allows for a single source.

In addition, the available flags are somewhat different (see below).

Flags mc cp offers not offered by mc mirror

  1. --rewind value: roll back object(s) to current version at specified time
  2. --version-id value, --vid value: select an object version to copy
  3. --attr: add custom metadata for the object (format: KeyName1=string;KeyName2=string)
  4. --continue, -c: create or resume copy session
  5. --tags: apply tags to the uploaded objects (eg. key=value&key2=value2, etc)
  6. --rewind value: roll back object(s) to current version at specified time
  7. (The --recursive, -r flag, but that's always true for mirror)

Flags offered by mc mirror not offered by mc clone:

Flags mc mirror offers not offered by mc cp

  1. --exclude value: exclude object(s) that match specified object name pattern
  2. --fake: perform a fake mirror operation
  3. --overwrite: overwrite object(s) on target if it differs from source
  4. --region value: specify region when creating new bucket(s) on target (default: "us-east-1")
  5. --watch, -w: watch and synchronize changes (This may be a big deal)

Consider using rclone as an alternative with additional flexibility. The Minio project is focussed on performance and being an excellent, simple S3 backend, not implementing every feature you could ask for (e.g., chunk size, throttling).

Trunk answered 15/1, 2022 at 21:5 Comment(0)
W
1

Important to note:

mc mirror only synchronizes the current object without any version information or metadata. To synchronize an object’s version history and metadata, consider using mc replicate or mc admin replicate.

https://min.io/docs/minio/linux/reference/minio-mc/mc-mirror.html

Wantage answered 12/10, 2022 at 13:21 Comment(0)
H
1

@Gordon Fogus: you forgot to mention that mc mirror has also the --remove flag in order to be sure that a file removed in remote is also removed in local.

Heidiheidie answered 13/10, 2022 at 18:48 Comment(1)
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewWiser

© 2022 - 2024 — McMap. All rights reserved.