mongocp is a fast CLI tool for copying MongoDB databases and collections from one server to another.
It is designed for migration and replication workflows where you want filtering, dry-run safety, and clear progress visibility per worker.
- Copy databases and collections from source to destination MongoDB.
- Include/exclude databases with wildcard patterns (for example:
dev*,prod_*). - Exclude system databases (
admin,local,config) by default. - Parallel copy with configurable workers.
- Default progress UI with stable one-line-per-worker bars.
- Copies secondary indexes.
- Dry-run mode to preview what would be copied.
go install github.com/kstieger/mongocp/cmd/mongocp@latestgo install github.com/kstieger/mongocp/cmd/mongocp@v0.1.0After installation, ensure your Go bin directory is in PATH.
mongocp -src "mongodb://root:xxxxx@source:27017/" -dst "mongodb://root:xxxxx@dest:27017/"mongocp \
-src "mongodb://root:xxxxx@source:27017/" \
-dst "mongodb://root:xxxxx@dest:27017/" \
-include-dbs "dev_*" \
-exclude-dbs "dev_tmp*" \
-worker 8mongocp \
-src "mongodb://root:xxxxx@source:27017/" \
-dst "mongodb://root:xxxxx@dest:27017/" \
-include-dbs "dev_*" \
-dry-run- Progress mode is enabled by default.
- In default progress mode, regular logs are suppressed and only fatal failures are printed.
- Setting
-log-level(or-loglevel) disables progress mode and enables normal logging.
-src(required): source MongoDB URI.-dst(required): destination MongoDB URI.-include-dbs: comma-separated include wildcard patterns.-exclude-dbs: comma-separated exclude wildcard patterns.-exclude-system_dbs: excludeadmin,local,config(default:true).-worker: number of parallel workers (default:10).-dry-run: preview copy operations without writing data.-log-level: logging level (info,debug,warn,error); disables progress mode when set.-loglevel: alias for-log-level.
GitHub Releases include prebuilt binaries for:
- Linux:
amd64,arm64 - macOS (Darwin):
amd64,arm64 - Windows:
amd64,arm64
go build -o out/mongocp ./cmd/mongocpgo test ./...golangci-lint runBefore committing and pushing:
- Run tests and lint:
go test ./...golangci-lint run
- Scan for secrets (for example with
gitleaks detect). - Verify docs/examples do not include real credentials, tokens, or private keys.
MIT. See LICENSE.