MySQL Clone Plugin: How to Copy Hundreds of GBs in a Flash Instead of Waiting for mysqldump

MySQL tutorial - IT technology blog
MySQL tutorial - IT technology blog

The nightmare of mysqldump as databases “bloat”

Watching the mysqldump progress bar crawl for 5-10 hours for a database of several hundred GBs is an exhausting experience. This traditional method (logical backup) actually reads every single record and writes it to a file as INSERT SQL statements. Upon restoration, MySQL has to laboriously execute those millions of statements to rebuild indexes—a process that consumes massive CPU and IO.

I once managed a MySQL 8.0 system with about 100GB of data. Previously, every server migration meant an all-night shift. Since using Clone Plugin, everything has changed completely. Instead of spending 4 hours on dumping and 6 hours on restoring, creating a complete replica now takes only about 15-20 minutes. If you need to quickly set up a Slave server or migrate data without long downtime, this is the ultimate solution.

Why is MySQL Clone Plugin incredibly fast?

Introduced in version 8.0.17, the Clone Plugin allows direct data copying from the Donor (source) to the Recipient (target) without shutting down the server. Its mechanism is very different.

It performs a Physical Backup. Instead of converting data into text, it moves the actual physical files (InnoDB tablespaces, redo logs…) from one server’s disk to another. The speed is no longer dependent on MySQL’s SQL processing power. It only depends on the network bandwidth and the SSD’s read/write speed.

3 advantages that make mysqldump obsolete:

  • Hits bandwidth limits: Copying speed usually reaches 80-90% of the network card’s limit (e.g., a 1Gbps network will reach about 100MB/s).
  • No intermediate files: Data flows directly from source to target, saving disk space that would otherwise be used for dump files.
  • Fully automated: The target server automatically configures and restarts with the new data without requiring manual intervention.

Prerequisites for “operating” the Clone Plugin

Don’t rush to type commands just yet. Ensure both sides match the following parameters to avoid mid-process errors:

  1. Version: Both servers must be on the exact same version (e.g., 8.0.35).
  2. Platform: Must be the same operating system (both Linux x64 or both Windows).
  3. InnoDB Configuration: The innodb_page_size parameters must be identical.
  4. Plugin: The mysql_clone.so file must be installed on both ends.

Hands-on: 4 steps to clone data over the network

Suppose the Donor (192.168.1.10) server has the data and Recipient (192.168.1.20) is the new server.

Step 1: Activate the Plugin

Execute this command on both servers:

INSTALL PLUGIN clone SONAME 'mysql_clone.so';

Step 2: Assign User Permissions

On the Donor, create a user with permissions to read system files:

CREATE USER 'clone_user'@'192.168.1.20' IDENTIFIED BY 'SuperSecurePass';
GRANT BACKUP_ADMIN ON *.* TO 'clone_user'@'192.168.1.20';

On the Recipient, grant permissions to perform data overwriting:

CREATE USER 'rcp_user'@'localhost' IDENTIFIED BY 'SuperSecurePass';
GRANT CLONE_ADMIN ON *.* TO 'rcp_user'@'localhost';

Pro tip: The CLONE_ADMIN privilege will automatically perform a SHUTDOWN after the cloning is complete so the server can load the new data.

Step 3: Define Trusted Sources

On the target server, you need to confirm that you will only receive data from this source server:

SET GLOBAL clone_valid_donor_list = '192.168.1.10:3306';

Step 4: Press the “Copy” Button

From the Recipient server, run the activation command:

CLONE INSTANCE FROM 'clone_user'@'192.168.1.10':3306 IDENTIFIED BY 'SuperSecurePass';

How to track progress (Performance Schema)

With large databases, waiting without knowing what the machine is doing can be nerve-wracking. Open a new Terminal tab and query the following table:

-- Check how many MBs have been copied
SELECT STAGE, STATE, CAST(BEGIN_TIME AS DATETIME) AS START, 
       CONCAT(TRUNCATE(DATA/1024/1024,2), ' MB') AS DATA_TRANSFERRED 
FROM performance_schema.clone_progress;

Practical experience: Always run the clone command in screen or tmux. If the SSH connection is lost midway and the command is interrupted, you will have to start over because the data will have been partially deleted.

“Hard-learned” lessons

Despite its power, the Clone Plugin still has points you need to note to avoid data loss:

  • Target data will be wiped: The CLONE_INSTANCE command will delete the entire existing database on the Recipient before copying the new one. Ensure the target server is empty.
  • Network bandwidth: On a 1Gbps card, the peak speed is 110MB/s. For a 1TB database, it still takes about 2.5 hours. With a 10Gbps network, the time is reduced to less than 20 minutes.
  • Docker Restart Policy: Since the plugin will shut down MySQL to restart, if you use Docker without setting restart: always, the container will die after cloning.

Conclusion

The MySQL Clone Plugin is a breakthrough for DBAs. It turns database migration from a nightmare into a smooth task. If you are managing databases over 50GB, ditch the habit of using dump files and switch to the Clone Plugin today to fully leverage modern hardware power.

Share: