Cloning a staging MongoDB and MySQL to your laptop without installing a single database client
Every week someone on my team needs a copy of our staging data on their laptop. Two databases, MongoDB and MySQL, a few gigabytes. For years the answer was a wiki page: install mongodump of the right major version, install the MySQL client, run four commands, wait, and hope the SSH session doesn't drop halfway through a 3 GB restore. I got tired of the wiki page and wrote dbclone , a small Go…
A small Go command line tool called dbclone enables cloning MongoDB and MySQL databases to your laptop without installing any database clients. The process involves using Docker images that already contain the necessary tools, such as mongodump, mongorestore, mysqldump, and mysql. The tool creates a Docker container and performs the dump and restore operations through it.
Version skew between the client and server is eliminated, as the same major version is used for both dumping and restoring. The tool does not require any staging or storage of dump files, making the process efficient. Each dump is piped directly into its restore, eliminating the need for cleanup steps. MySQL table groups are split into size-balanced chunks, each with its own snapshot, ensuring a consistent point in time.
The tool retries failed streams three times with backoff, and it never writes passwords on the command line. This tool is meant for development data and not for backups.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.