v0.1.1 · open source · MIT · Go

Clone MongoDB & MySQL
between any two servers

dbclone: Pick databases or single tables.

$go install github.com/phuthuycoding/dbclone@latest
★ Star on GitHub Download binaries
~/project — dbclone

Animated demo: dbclone checks Docker and the local mongodb and mysql containers, the user clones from the staging profile to local and picks three databases, and three progress bars stream them in parallel, including one automatic retry, until all databases are done.

Features

Move real data anywhere, without the scripts

One command replaces the dump-copy-restore dance — in whichever direction you need. dbclone picks the work apart, runs it in parallel and keeps you informed the whole way.

🔀

Any direction

Save servers as profiles — staging, prod, a teammate's box — and clone from any of them to any other. Your Docker containers are the built-in local.

🛡️

Safe by default

Writing anywhere but local means typing the target's name. Dropping whole databases only works on local, and a server is never cloned onto itself.

🐳

Nothing to install

Runs mongodump, mongorestore, mysqldump and mysql inside your local official containers — client versions always match the server.

⚡

Parallel streaming

One weighted pool shared by every database, biggest work first. Dumps pipe straight into restores — no dump files on disk.

🎯

Pick tables, not just databases

Tick whole databases or narrow any of them to the tables and collections you need. Everything else stays untouched.

🔁

Survives flaky links

Each stream retries three times with backoff; errors no retry can fix, like access denied, stop at once. Big collections run on their own, so a drop only re-copies what was lost.

📊

Live progress

A line per database: current table, active streams, percent, bytes, speed and time — plus a log file per database.

🔒

Secrets stay secret

Passwords travel as environment variables, never on a command line. Profiles are saved with mode 0600 and every log line is scrubbed of credentials.

🩺

Guided setup

dbclone -check verifies Docker and your containers and prints the exact command to fix anything missing.

🧩

Pluggable engines

MongoDB and MySQL today. Engines are adapters behind one interface — scheduling, retries and UI come for free.

How it works

From any profile, to any profile

Every stream is a pipe that runs inside your local container, with the official tools. Data never touches your disk as a dump file.

Sourcestaging · prod · local
Local containerofficial mongo / mysql image
dump──pipe──▶restore
Targetlocal · staging · any profile

MongoDB

Collections of 64 MiB or more get their own stream; the rest, views included, share one more that copies several collections at once.

MySQL

Tables are split into size-balanced groups, one stream each. Triggers, views, routines and events follow once the data is in.

Scheduling

Streams from all databases share -j slots and start biggest first, so a slot freed by a small database goes straight to a big one.

Get started

Up and running in a minute

You need Docker with the official mongo and/or mysql images running locally — their tools do the work. dbclone checks this for you, then helps you add your servers as profiles.

Install

go install github.com/phuthuycoding/dbclone@latest
# or grab a binary for Linux, macOS, Windows
# from GitHub Releases

Check your setup

dbclone -check
✓ Docker  29.8.2
✓ mongo: local container "mongodb"  running
✓ mysql: local container "mysql"  running

Clone

dbclone                        # guided: from, to, pick
dbclone -from prod -only mysql:app.users
dbclone -from local -to staging \
        -only mysql:app -confirm staging
Reference

Flags

FlagDefaultWhat it does
-fromaskedSource profile (local = your Docker containers)
-tolocalTarget profile
-confirmThe target's name; required to write to a non-local target without the prompt
-j8Global pool: concurrent dump→restore streams across all databases
-w4Max streams for one database
-onlyengine:db or engine:db.object, comma separated; skips the picker
-alloffClone every database on the source
-freshoffDrop each wholly-cloned database on the target first, for an identical copy — local only
-yesoffDo not ask before overwriting databases on the local target
-checkCheck Docker and the local containers, then exit
-setupoffAdd, edit or delete connection profiles
-configuser config dirProfiles file (saved with mode 0600)
-logslogsPer-database tool output, one folder per run
FAQ

Questions

Do I need mongodump or mysqldump installed?

No. dbclone runs the dump and restore tools that already ship in the official mongo and mysql images, inside your local containers. You only need Docker.

Can I clone only some tables or collections?

Yes. After picking databases you can narrow any of them down to specific tables or collections, or pass them on the command line: dbclone -only mongo:shop.orders,mysql:app.users.

Can I copy data from local up to staging, or between two servers?

Yes. Save your servers as profiles and clone from any profile to any other, including the built-in local profile for your Docker containers: dbclone -from local -to staging. Writing to anything but local requires typing the target's name, -fresh is only allowed on local, and a server is never cloned onto itself.

What happens to data that already exists on the target?

Objects that exist on the source are dropped and recreated on the target; objects that exist only on the target are kept. With -fresh (local target only), a database cloned whole is dropped first so the copy is identical to the source. dbclone lists everything it will write and asks first.

Is dbclone a backup tool?

No — it is built for development data. MySQL table groups are dumped in separate transactions, so a copy is not one consistent point in time across tables.

What if the connection to staging drops during a copy?

Every stream is retried up to three times with backoff, and restores drop-and-recreate, so a retry starts clean. Large MongoDB collections run as their own streams, so only the affected collection is copied again. On a busy source, lower the load with -j 3 -w 2.