Percona XtraBackup

Also known as: XtraBackup

On this page 7

Percona XtraBackup is an open-source utility that creates hot physical backups of MySQL and Percona Server for MySQL by copying InnoDB data files while the server keeps accepting reads and writes. In backup & recovery for relational databases, XtraBackup is the most widely used alternative to logical dumps for large MySQL installations, because it copies files at disk speed instead of exporting every row as SQL.

XtraBackup, as it is usually called, captures a consistent image by recording the InnoDB redo log during the copy and replaying it in a separate prepare step. The resulting backup can be restored in a fraction of the time a mysqldump file needs, and it serves as the base for point-in-time recovery and for building new replicas.

How XtraBackup produces a consistent hot backup

XtraBackup achieves consistency by combining a fuzzy file copy with redo log capture. The data files it copies are internally inconsistent, because pages change during the copy, but every change is also written to the redo log, which XtraBackup reads continuously from the moment the backup starts.

  1. A redo log copying thread starts reading the InnoDB redo log from the current log sequence number, or LSN.
  2. Data file threads copy the InnoDB tablespaces page by page, optionally in parallel with --parallel.
  3. A short backup lock is taken to copy non-InnoDB files and to record a consistent binary log position.
  4. The redo log thread stops at an LSN that matches the lock point, and metadata files such as xtrabackup_checkpoints are written.

The backup is not usable immediately. The prepare phase (xtrabackup --prepare) performs the same crash recovery that InnoDB runs after a power loss: it applies the captured redo log to the copied pages and rolls back uncommitted transactions. Only a prepared backup can be copied back into a data directory.

The three main phases differ in where they run and what they cost.

PhaseCommand optionWhat happensImpact on the server
Backup--backupCopies files and redo logExtra read I/O, brief backup lock
Prepare--prepareApplies redo, rolls back open transactionsNone, runs on the backup copy
Restore--copy-back or --move-backPlaces files into an empty data directoryServer must be stopped
XtraBackup phases and their effects

Backup types and key features

Beyond full backups, XtraBackup supports incremental backups that copy only pages whose LSN is newer than the previous backup. Because every InnoDB page header stores the LSN of its last change, the tool can identify changed pages without a separate change tracking mechanism, although it still has to read every data file to find them.

FeaturePurposePractical note
Full backupComplete physical copyBase for every restore chain
Incremental backupCopies changed pages onlyPrepare with --apply-log-only until the last step
CompressionReduces backup sizeSupports zstd and lz4 in recent versions
EncryptionProtects data at restKeys must be stored separately
Streaming with xbstreamSends output to another host or object storageAvoids local disk space for the copy
Partial backupSelected databases or tablesRestore requires transportable tablespace import
Main XtraBackup capabilities

The version of XtraBackup must match the server major version. XtraBackup 2.4 serves MySQL 5.6 and 5.7, while the 8.0 and later series follow the MySQL 8 line closely; a tool older than the server may refuse to run when the redo log format has changed. MariaDB uses its own fork, Mariabackup, because its InnoDB format diverged.

XtraBackup compared with other MySQL backup methods

XtraBackup is a physical backup tool, so it competes mainly with file system snapshots and commercial hot backup products, while logical tools such as mysqldump and MySQL Shell dump utilities answer different needs.

MethodBackup typeRestore speedMain limitation
Percona XtraBackupPhysical, hotFast, file copy plus prepareSame major version needed for restore
mysqldumpLogicalSlow, replays SQLImpractical for very large datasets
MySQL Shell dumpLogical, parallelModerateStill rebuilds indexes on load
Storage snapshotPhysical, crash consistentVery fastDepends on volume manager or cloud
MySQL Enterprise BackupPhysical, hotFastCommercial license
Comparison of MySQL backup approaches

A physical backup restores the exact on-disk state, including fragmentation, which makes it fast but not portable across major versions or storage engines. A logical dump is slower but can be loaded into a different version, used to migrate between platforms or inspected by a person.

Using XtraBackup for recovery and replicas

XtraBackup is the usual first step of point-in-time recovery for MySQL. The file xtrabackup_binlog_info records the binary log file and position, or GTID set, at the moment of consistency; after restoring the prepared backup, the administrator replays binary logs from that position up to the moment just before the incident.

The same coordinates make XtraBackup a standard way to seed a new replica. A streamed backup is prepared on the target host, the server starts on the restored files, and replication begins from the recorded GTID set without locking the source for more than a few seconds.

ScenarioSteps with XtraBackupResult
Hardware failureRestore latest full and incrementalsServer back at backup time
Accidental DROP TABLERestore, then replay binary logs to just before the dropPoint-in-time recovery
New replicaStream backup, prepare, start replicationReplica without source downtime
Single table lossPartial restore with --export and tablespace importTable recovered online
Typical recovery scenarios

Limitations and operational pitfalls

The most dangerous mistake with XtraBackup is never testing the restore. A backup that has not been prepared and started on a test server is only an assumption, and problems such as missing encryption keys or version mismatches surface only at restore time.

  • Redo log overwrite: on a very busy server, the redo log can wrap before XtraBackup copies it, which aborts the backup unless the log is large enough.
  • Lock waits: long-running queries can delay the backup lock and stall writes behind it.
  • Disk space: a full uncompressed backup needs roughly the size of the data directory, and prepare needs space for the redo log.
  • MyISAM and other engines: non-transactional tables are copied under lock and can extend the locked period.
  • Incremental chains: losing one incremental backup breaks every later restore in that chain.

A sound policy combines XtraBackup with a backup retention policy, continuous binary log archiving and scheduled restore drills, so that the measured recovery time objective is known rather than estimated.

The idea in brief

Percona XtraBackup makes a copy of a running MySQL database without switching it off. It is like photocopying a busy ledger while people keep writing in it. The copier notes every new entry made during the copy. Afterward, it adds those entries, so the final copy is complete and consistent.

It copies files directly instead of rewriting the data. That makes restoring much faster than with export tools. Speed matters when a large database must come back quickly.

A practical scenario

An online ticketing company runs a 1.8 TB MySQL 8.0 database that handles sales around the clock. A nightly mysqldump had grown to six hours and a test restore took more than a day, which was far beyond the four-hour recovery target. The database team switches to XtraBackup with a weekly full backup, daily incremental backups and continuous binary log archiving, all streamed with zstd compression to object storage.

Some months later, a faulty deployment deletes several thousand bookings at 14:05. The team restores the latest full backup and five incrementals to a standby server, prepares them in about 40 minutes and replays binary logs up to 14:04. The data is recovered in under three hours with no lost sales, and the restore drill they had rehearsed quarterly matched the real duration within 15 minutes.