Skip to content

MySQL Tutorial Backup, Recovery and Maintenance

Physical Backups: CLONE, XtraBackup and Snapshots

Lesson 286 of 308 4 min read By Deepak Paswan Updated Oct 5, 2026

A physical backup copies the files that MySQL uses (tablespaces, redo logs, system files), not the SQL that creates the data. Backups and restores are much faster than a dump, which matters for databases of tens or hundreds of gigabytes. The price is portability: a physical backup is for the same major version (and usually the same operating system and architecture).

Never copy the data directory of a running server

Copying /var/lib/mysql with cp or rsync while MySQL is running gives a corrupted, inconsistent copy: pages change while they are being copied. The server must be stopped cleanly, or you must use a tool that handles the live server. The options:

ToolEditionHow
CLONE pluginMySQL Community (built in since 8.0.17)A built-in SQL statement that copies a consistent InnoDB snapshot
Percona XtraBackupFree, open sourceCopies files while tracking the redo log, supports incremental backups and compression
MySQL Enterprise BackupCommercial MySQL Enterprise EditionOracle’s hot backup tool
Filesystem or cloud snapshots (LVM, ZFS, EBS, VM snapshots)AnyInstant snapshot of the volume. Consistent for InnoDB only when the data and logs are on one volume, and recovery then runs like crash recovery
Cold backupAnyStop mysqld, copy the directory, start again. Simple, but it means downtime

The CLONE plugin, for real

CLONE makes a consistent copy of all InnoDB data while the server keeps running. It needs a plugin, installed once (this is the Windows library name, on Linux it is mysql_clone.so):

query.sql
SQL
INSTALL PLUGIN clone SONAME 'mysql_clone.dll';

SELECT PLUGIN_NAME, PLUGIN_STATUS FROM information_schema.PLUGINS WHERE PLUGIN_NAME = 'clone';
Output
OUTPUT
+-------------+---------------+
| PLUGIN_NAME | PLUGIN_STATUS |
+-------------+---------------+
| clone       | ACTIVE        |
+-------------+---------------+

Then clone to a new directory (it must not exist yet, and the MySQL server’s operating system user must be able to create it):

query.sql
SQL
CLONE LOCAL DATA DIRECTORY = '/backups/clone-2026-10-05';

SELECT STATE, ERROR_NO, ERROR_MESSAGE FROM performance_schema.clone_status;
Output
OUTPUT
+-----------+----------+---------------+
| STATE     | ERROR_NO | ERROR_MESSAGE |
+-----------+----------+---------------+
| Completed |        0 |               |
+-----------+----------+---------------+

On a real MySQL 8.4 test server the clone directory afterwards contained a complete data directory:

Output
OUTPUT
#clone   #innodb_redo   ib_buffer_pool   ibdata1   learn   mysql   mysql.ibd   shop   sys   undo_001   undo_002

To prove it is a real, working backup, a second MySQL server was started on the cloned directory (on another port), and it contained the data:

terminal
BASH
mysqld --datadir=/backups/clone-2026-10-05 --port=3399
query.sql
SQL
SELECT @@port AS port, (SELECT COUNT(*) FROM shop.orders) AS orders, (SELECT COUNT(*) FROM shop.customers) AS customers;
Output
OUTPUT
+------+--------+-----------+
| port | orders | customers |
+------+--------+-----------+
| 3399 |      6 | 5 |
+------+--------+-----------+

(Values from the real test; the table layout is shortened.) A few important points:

  • CLONE copies InnoDB data. Other engines’ files are copied only partly (MyISAM tables are not consistent), and configuration files and the binary logs are not included.
  • A remote clone (CLONE INSTANCE FROM 'user'@'host':3306 IDENTIFIED BY '...') copies from one server to another over the network. It is a fast way to build a new replica.
  • It needs the account to have the BACKUP_ADMIN privilege (on the donor), and CLONE_ADMIN on a recipient.
  • Cloning blocks some DDL (ALTER TABLE, DROP TABLE) on the donor while it runs.
  • After restoring a clone, the server runs crash recovery on start, like after a power cut. That is normal for hot backups.

XtraBackup

Percona XtraBackup is the common free tool for hot physical backups:

terminal
BASH
# take a full backup
xtrabackup --backup --user=backup --password --target-dir=/backups/full-2026-10-05

# prepare it (apply the redo log so the files are consistent)
xtrabackup --prepare --target-dir=/backups/full-2026-10-05

# restore: with MySQL stopped and an empty data directory
xtrabackup --copy-back --target-dir=/backups/full-2026-10-05
chown -R mysql:mysql /var/lib/mysql

The three phases are always backup, prepare, restore. An unprepared backup is not consistent. XtraBackup also offers incremental backups (only pages changed since the last one), compression and encryption. Use the XtraBackup version that matches your MySQL version.

Snapshots

Cloud disks and storage systems can take an instant snapshot. For MySQL:

  • Keep data and redo logs on the same volume, so that one snapshot is consistent.
  • InnoDB recovers from the snapshot as from a crash, which works because InnoDB is crash-safe.
  • With sync_binlog = 1 and innodb_flush_log_at_trx_commit = 1 (the safe defaults), no committed transaction is lost.
  • For a more controlled snapshot, run FLUSH TABLES WITH READ LOCK, snapshot, then UNLOCK TABLES. That blocks writes for a moment.
  • Test a restore from a snapshot like any other backup.

Choosing

SituationChoice
Small database (up to a few GB), simple needsmysqldump nightly + binary logs
Large database, short RTOPhysical backup (XtraBackup, CLONE, snapshots) + binary logs
Upgrading across versions, moving platformsmysqldump or MySQL Shell dump
Building a replicaCLONE, XtraBackup, or a snapshot
Managed cloud databaseThe provider’s automated backups and point-in-time restore. Also keep an independent logical dump

Physical backups and the binary log together give you point-in-time recovery: restore the files, then replay the log from the position stored in the backup (Point-in-Time Recovery).

dangerous
A copy is not a backup until it starts
Check physical backups by starting a MySQL server on them (as the clone above was started) and running queries. Files that look right can still be unusable.