Skip to content
Latchkey

mc cp: Copy Objects with the MinIO Client

mc cp copies objects between the local filesystem and any S3-compatible store configured as an mc alias.

The MinIO client (mc) speaks S3 to MinIO, AWS S3, and other S3-compatible backends. mc cp is its straightforward per-object copy, addressing objects as alias/bucket/key.

What it does

mc cp copies one or more objects between a source and a target, where each side is a local path or alias/bucket/prefix. With --recursive it copies whole directory trees. It does not delete anything at the target; use mc mirror for that.

Common usage

Terminal
mc cp ./build.tar.gz myminio/artifacts/build-${GITHUB_SHA}.tar.gz
mc cp --recursive ./dist myminio/www/
mc cp --recursive myminio/cache ./cache

Options

FlagWhat it does
--recursive, -rCopy directories recursively
--attr <k=v>Set object metadata (e.g. Content-Type)
--preserve, -aPreserve file attributes
--continue, -cResume an interrupted copy
--encrypt-key <key>Client-side or SSE-C encryption key

In CI

mc reads aliases from ~/.mc/config.json; in CI set them with mc alias set from secrets, or point MC_HOST_<alias> at a full URL including credentials so nothing is written to disk. Use --recursive for directory uploads and set Content-Type via --attr when serving files from a bucket.

Common errors in CI

"mc: <ERROR> Unable to validate source ... The specified bucket does not exist" means a wrong bucket or a missing mc mb. "Access Denied." (S3 AccessDenied) means the key lacks permission for the operation. "The request signature we calculated does not match" (SignatureDoesNotMatch) means a wrong secret key or a clock skew. "The Access Key Id you provided does not exist" is InvalidAccessKeyId, a wrong or empty access key.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →