Skip to content
Latchkey

mc mirror: Sync Directories to S3-Compatible Storage

mc mirror synchronizes a source directory or bucket to a target, copying new and changed objects and optionally deleting extras with --remove.

mirror is the MinIO client answer to rsync and rclone sync. By default it is additive; add --remove to make the target match the source exactly, which suits static-site deploys.

What it does

mc mirror walks the source and copies objects that are new or changed to the target. Without --remove it never deletes; with --remove it deletes target objects missing from the source, producing an exact mirror. --watch keeps mirroring on file changes.

Common usage

Terminal
# additive upload of a directory tree
mc mirror ./dist myminio/www
# exact mirror: also delete removed files
mc mirror --overwrite --remove ./dist myminio/www
# preview only
mc mirror --dry-run --remove ./dist myminio/www

Options

FlagWhat it does
--overwriteOverwrite objects that already exist
--removeDelete target objects not present in the source
--dry-runPrint actions without executing them
--watch, -wContinuously mirror on source changes
--exclude <pattern>Skip matching paths

In CI

Use mc mirror --remove for static-site deploys so deleted pages are purged; run --dry-run first in review builds to log what would change. --remove needs delete permission on the target, so grant s3:DeleteObject on the prefix. Keep source and target order straight: source first, target second.

Common errors in CI

"Access Denied." when --remove is set but not on plain uploads means the key lacks s3:DeleteObject. "The specified bucket does not exist" (NoSuchBucket) means create it first with mc mb. "Unable to initialize ... The request signature we calculated does not match" (SignatureDoesNotMatch) is a wrong secret or clock skew on the runner.

Related guides

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