Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

MySQL & MariaDB in Depth  Module 10 – Backups, restores and point-in-time recovery

Physical backups: XtraBackup and mariadb-backup

Copy a running server as data files with the MySQL clone plugin, Percona XtraBackup or mariadb-backup, and pick the one that fits the server and its host.

  • Advanced
  • 15 minutes
  • Examples run with MySQL 8.4.11 and Python 3.14.8
  • By MySmartCoPilot
Free core, Pro depth: 5 of 15 minutes free
Free: A hot copy is files plus the redo written meanwhile · The server and its host choose the tool · Why physical restores are faster for large databases. With a pass: 2 in-depth parts and 3 interview answers, about 10 minutes.

What you will learn

  • Explain why a hot physical copy of InnoDB needs the redo written during the copy
  • Pick between the clone plugin, Percona XtraBackup and mariadb-backup for a server you must copy
  • Copy a running MySQL 8.4 instance locally and from a donor, with the grants and the donor list
  • Describe the backup, prepare and copy-back workflow of Percona XtraBackup and the version-match rule

Before you start

What you’ll learn · Before you start

What you will learn

  • Explain why a hot physical copy of InnoDB needs the redo written during the copy
  • Pick between the clone plugin, Percona XtraBackup and mariadb-backup for a server you must copy
  • Copy a running MySQL 8.4 instance locally and from a donor, with the grants and the donor list
  • Describe the backup, prepare and copy-back workflow of Percona XtraBackup and the version-match rule

Before you start

On this page

An operator must replace a dying database host that holds 220 GB of InnoDB files, and reloading last night’s dump would rebuild every row and index before the new host could serve. A physical copy skips that work: the new host starts on the pages the old one already wrote and catches up from a saved binary-log position. A physical backup: A backup that copies the server's binary data files — InnoDB tablespaces, redo logs, binary logs — and is restored by copying them back; faster than a logical reload but tied to the server's version and layout. is the files the server is already writing, carried to another folder or host.

Three tools make one: the clone plugin inside MySQL, Percona XtraBackup: Percona's open-source program for physical hot copies of MySQL and Percona Server; the 8.4 line supports MySQL 8.4 and Percona Server 8.4 and runs on Linux as packages, tarballs or Docker images. on the host, and mariadb-backup: MariaDB's physical backup program, forked from Percona XtraBackup 2.3.8 and shipped with MariaDB. It copies InnoDB, Aria and MyISAM tables on Linux and Windows. for MariaDB servers. All three take a A copy made while the server keeps writing, so the tool must also capture the InnoDB redo written during the copy; the opposite of a cold copy where the server is stopped first., and the server and its host decide which one fits.

A hot copy is files plus the redo written meanwhile

A physical backup is not a stream of SQL. It is the data files themselves: InnoDB tablespaces, the undo logs, the redo log and the server’s metadata, read while the server runs. One idea underpins every hot-copy tool: the files copied one at a time, with the server still writing to them, do not match any single moment. The copy, on its own, is inconsistent. Step through the five stages, and the shortcut that skips one:

Interactive · stage by stage How a copy of a running server becomes a data directory Step through the five stages and the shortcut that fails. Each stage names the step both XtraBackup and the clone plugin take.
How a copy of a running server becomes a data directory, step 6 of 6. Showing Copy the data files, Copy the redo, Record where it ends, Apply the copied redo, Start a server on it. In focus: Start a server on it.skip the redoCopy the data fileswhile writes go onCopy the redowritten during the copyRecord where it endsbinlog file, offset, GTIDsApply the copied redoInnoDB crash recoveryStart a server on itone consistent moment

The drawing shows the whole scene; its 6 steps are listed below.

Every step as text
  1. The files, copied while in use. The tool reads each tablespace file while the server keeps writing to it. Pages changed before the tool reached them arrive new and pages changed after arrive old, so the copied files on their own match no single moment.
  2. The redo written meanwhile. InnoDB writes every change to its redo log before the change reaches a data file. The tool keeps copying the redo written from the start of the file copy to its end, so every change the files may have missed is in the copy as well.
  3. Where the copy stands. The copy ends at one point of the server's history. The tool records the binary log file, the offset in it and the GTID set of that point, which is where a new replica or a point-in-time restore carries on from.
  4. A shortcut that fails. Started straight on the copied files, InnoDB finds pages from different moments and stops rather than run on damaged data. Percona's documentation says so for an unprepared XtraBackup copy.
  5. The redo, applied. InnoDB's crash recovery replays the copied redo onto the copied pages and rolls back what was not committed. XtraBackup runs it as a separate prepare step; a clone runs it when a server first starts on the copy.
  6. A data directory again. After recovery the copy is an ordinary data directory, consistent at the moment the copy ended. A server started on it finds the rows of that moment, and not a row written later.

The redo log: InnoDB's on-disk log of the changes made to pages, written before the changed pages reach the data files. After a crash, recovery replays it, so committed changes that were missing from the data files are restored. More in “Redo log, doublewrite and crash recovery” closes the window. InnoDB writes every change to redo first, before the change reaches a data file. A tool that keeps copying the redo written from the start of the file copy to its end carries, with it, every change the files may have missed. After the redo is applied, the folder is a consistent data directory of one point in the server’s history.

Checkpoint

Check: What a physical backup copies, and why it also needs the redo

  1. Question 1 of 2 Which description best fits what a physical backup of a running MySQL server contains?

    Choose one answer.

    Show the answer: Question 1 of 2

    Answer: The InnoDB data files plus the redo written during the copy

    The files alone do not match any single moment, so every hot physical tool also carries the redo written during the copy and applies it on the way to a consistent folder.

  2. Question 2 of 2 What goes wrong if you start a server directly on the raw files a physical backup copied, without applying the copied redo first?

    Choose one answer.

    Show the answer: Question 2 of 2

    Answer: InnoDB finds pages from different moments and stops

    Percona's prepare page says files copied at different times are not point-in-time consistent until they are prepared, and that InnoDB started on them detects corruption and stops. XtraBackup applies the redo in a separate --prepare step; a clone applies it when a server first starts on the copy.

The server and its host choose the tool

The clone plugin: A server plugin, mysql_clone.so, that copies a running donor server's data over the network into a recipient server: CLONE INSTANCE FROM removes the recipient's own schemas, tables and binary logs and writes the donor's data in their place. More in “Set up GTID replication with TLS” is mysql_clone.so (.dll on Windows), loaded by INSTALL PLUGIN clone and driven by CLONE LOCAL DATA DIRECTORY or CLONE INSTANCE FROM ...; it copies InnoDB only, and MyISAM or CSV tables arrive on the copy as empty tables. Percona XtraBackup is a Linux program on the database host that reads the files directly; its 8.4 line supports MySQL 8.4 and Percona Server 8.4 and refuses older or newer servers by default. MariaDB’s mariadb-backup, forked from Percona XtraBackup 2.3.8 and shipped by MariaDB, is the physical tool a MariaDB server pairs with; it runs on Linux and Windows and copies InnoDB, Aria and MyISAM tables alike. Answer the table’s questions for your own server:

Interactive · answer and compare Which physical copy tool fits your server Answer three questions about the server and what the copy is for. The table rules out the tools that cannot serve it.
Which server do you need to copy?
Which operating system runs the database server?
What is the copy for?

Answer the questions above: the table then marks what fits your case and says why the rest does not.

The clone plugin, Percona XtraBackup and mariadb-backup against the four facts that decide between them.
Tool Servers it copies Where it runs What you are left with Engines it copies
Clone plugin Runs as: a plugin inside MySQL, driven by SQL statements Good MySQL 8.4, with donor and recipient in the same release series Good wherever MySQL runs, with donor and recipient on the same platform Mixed a full copy each time: a data directory or a running server, no backup chain Mixed InnoDB only; MyISAM and CSV tables arrive as empty tables
Percona XtraBackup 8.4 Runs as: a program on the database host Good MySQL 8.4 and Percona Server 8.4; it refuses 8.0 and 9.x servers Mixed Linux: Percona ships packages, tarballs and Docker images Good backup folders to keep: full or incremental, compressed or encrypted Good InnoDB, MyISAM and MyRocks
mariadb-backup Runs as: a program on the database host Mixed MariaDB only, run in the version that matches the server Good Linux and Windows Good backup folders to keep: full, incremental or partial Good InnoDB, Aria, MyISAM and MyRocks
How the answers decide
  • “Which server do you need to copy?” MariaDB: rules out Clone plugin and Percona XtraBackup 8.4. The clone plugin and XtraBackup 8.4 copy MySQL 8.4 servers; MariaDB documents mariadb-backup for its own servers.
  • “Which server do you need to copy?” MySQL 8.4: rules out mariadb-backup. mariadb-backup is documented for MariaDB servers; for MySQL 8.4 the documented tools are the clone plugin and XtraBackup 8.4.
  • “Which operating system runs the database server?” Windows: rules out Percona XtraBackup 8.4. Percona documents XtraBackup for Linux hosts only.
  • “Which operating system runs the database server?” macOS: rules out Percona XtraBackup 8.4 and mariadb-backup. Neither program is documented for macOS. The clone plugin runs inside the server, so it copies wherever MySQL itself runs.
  • “What is the copy for?” Backups kept for days or weeks: adds a caveat to Clone plugin. Every clone is a full copy with no incremental mode, so two weeks of daily copies means fourteen full data directories.
  • “What is the copy for?” A second server, today: adds a caveat to Percona XtraBackup 8.4 and mariadb-backup. A backup folder is prepared and copied back before a server runs on it; a clone from a donor ends with the recipient running on the copy.

A MySQL 8.4 server on macOS has one fit: the clone plugin, which runs wherever MySQL runs. A MySQL server on Linux has two: the clone plugin, or XtraBackup for backup folders kept for weeks. A MariaDB server needs mariadb-backup: MariaDB ships no clone plugin, and XtraBackup 8.4 supports only MySQL and Percona Server 8.4.

Checkpoint

Check: Clone plugin, XtraBackup, mariadb-backup

  1. Question 1 of 2 Your database server runs MariaDB on Linux. Which physical tool is the documented fit?

    Choose one answer.

    Show the answer: Question 1 of 2

    Answer: mariadb-backup

    Each physical tool is tied to a server family. MariaDB forked mariadb-backup from Percona XtraBackup 2.3.8 and keeps it in step with MariaDB's own file format.

  2. Question 2 of 2 Which of these are correct about the clone plugin on MySQL 8.4?

    Choose every answer that is right.

    Show the answer: Question 2 of 2

    Answer:

    • It clones InnoDB tables only
    • MyISAM and CSV tables arrive on the recipient as empty tables

    The clone plugin is a MySQL plugin that copies InnoDB files. Its limitations page is explicit about MyISAM and CSV: the tables arrive on the recipient as empty, so a shop that still uses them pairs clone with a dump of those tables.

Why physical restores are faster for large databases

A logical restore pays for every row: the SQL file is parsed, every INSERT runs through the optimiser, every secondary index is built again from the rows. A physical restore pays once, for the bytes. Take the 220 GB host of the opening and a disk that writes 400 MB per second: 220,000 MB ÷ 400 MB/s = 550 s, a little over nine minutes to put the pages back, before the redo is applied. The table compares the two restores of that host:

The 220 GB host Physical restore Dump reload
Secondary indexes already in the pages built again from the rows
Time to write the data 550 s at 400 MB/s no formula: it depends on the schema

Both times stay estimates until a restore drill: A rehearsed restore of a real backup into a throwaway server, timed and checked against the source, so the backup and its recovery time are proven before a real failure. More in “Backup strategy, RPO, RTO and restore drills” measures them on your own hardware. A dump still wins its own jobs. It is human SQL, so a reader may edit it, move one schema into a test server, or restore the shape of a dropped table alone, and it crosses storage engines and major versions a physical copy will not. Teams keep both: a nightly dump for selective restores, a weekly physical copy for a fast full restore.

Checkpoint

Check: Why a physical restore wins for large databases

  1. Question 1 of 2 Why does a physical restore of a 200 GB InnoDB database usually finish faster than a dump reload?

    Choose one answer.

    Show the answer: Question 1 of 2

    Answer: A physical restore writes bytes once; a dump reload rebuilds every index from SQL

    Index rebuilds dominate a dump reload at scale. A physical copy already carries the index pages, so the restore is a byte copy and a start, not a parse-and-rebuild of every statement.

  2. Question 2 of 2 Which of these cases is a reason to keep a logical dump even though a physical copy restores faster?

    Choose every answer that is right.

    Show the answer: Question 2 of 2

    Answer:

    • Moving the data to a server on a different major version
    • Restoring the shape of a dropped table without its data

    A dump is a text artefact a reader can edit, replay in part, and move across server versions. A team runs the physical copy for speed and keeps the dump for the jobs the physical copy cannot do.

Clone a running MySQL 8.4 instance, local and remote Pro: opens with a Pro, Premium or Ultimate pass

The clone plugin is MySQL’s own hot-copy tool, driven by SQL. Two statements cover the common cases: CLONE LOCAL DATA DIRECTORY = '/absolute/path' writes a copy on the same server, and CLONE INSTANCE FROM 'user'@'host':port copies one running server, the clone donor: In a MySQL clone, the running server whose InnoDB data files are copied, either into a folder on the same host or to another server., into another, the clone recipient: In a remote MySQL clone, the server that receives the donor's copy of the data files in place of its own data.. Both run below on throwaway MySQL 8.4.11 servers, with the grants, the donor-list guard, the restart and the clone-status row a replica reads to catch up.

In this part:

  • A local clone, start to finish
  • Remote clone: the grants, the donor list, the restart

2 runnable examples (clone_instance_session.py, clone_local_session.py, mysql_session.py) · about 6 minutes

Opening this part with your pass…

This part opens with any MySmartCoPilot pass.

  • Pro pass · 1 week₹79$2.99
  • 30 days₹179$5.99
  • 1 year₹1,699$45

One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.

It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).

XtraBackup and mariadb-backup: backup, prepare, restore Pro: opens with a Pro, Premium or Ultimate pass

Percona XtraBackup and mariadb-backup copy the same kind of files as the clone plugin, but outside the server process, as programs on the host. The workflow is three verbs plus a start: xtrabackup --backup reads the files and the redo as the server runs, xtrabackup --prepare applies the copied redo and rolls back uncommitted work, xtrabackup --copy-back writes the prepared folder into an empty data directory, and mysqld starts on it. The version-match rule decides whether a backup is safe to take and prepare at all.

In this part:

  • A full and an incremental backup, on a Linux host
  • Match XtraBackup to the server, and when the version-check flag is risky
  • mariadb-backup runs the same three steps on MariaDB
  • Key takeaways from these parts

4 runnable examples (Python, Shell) · about 7 minutes

Opening this part with your pass…

This part opens with any MySmartCoPilot pass.

  • Pro pass · 1 week₹79$2.99
  • 30 days₹179$5.99
  • 1 year₹1,699$45

One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.

It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).

Practise

The adaptive session asks about the hot copy, the choice of tool and restore speed.

Practice that adapts to you

Practise this lesson

6 questions about 5 ideas of this lesson. Each answer is explained at once, and what you get right is kept in this browser.

  1. Question 1 of 6 A hot copy of a running MySQL server has finished the file copy. The server has kept writing. Which pair of actions makes the copy consistent for a fresh server to start on?

    Choose one answer.

    Show the answer: Question 1 of 6

    Answer: Copy the InnoDB redo written during the file copy, then apply it onto the copied pages

    The redo written while the files were read is the record of every change the files may have missed. Applied to the copied pages it brings the folder to one moment; the binary log is for carrying on from that moment.

  2. Question 2 of 6 A database stores a payments ledger in a MyISAM table and the rest of its tables in InnoDB. The team runs the clone plugin for a nightly copy. What arrives on the copy?

    Choose one answer.

    Show the answer: Question 2 of 6

    Answer: The InnoDB tables with their data; the MyISAM payments table as an empty table

    The clone plugin is InnoDB-only. A shop that still uses MyISAM for one table pairs the nightly clone with a targeted mysqldump of that table, or converts it to InnoDB.

  3. Question 3 of 6 You run MySQL 8.4 on Windows Server and want a physical backup folder you can keep for a week. Which of the three tools fits?

    Choose one answer.

    Show the answer: Question 3 of 6

    Answer: The clone plugin

    The platform narrows the choice before any other criterion. The clone plugin is the one that runs on Windows, because it is a MySQL plugin and lives inside the server.

  4. Question 4 of 6 A company runs its billing database on MySQL 8.4 on a Windows Server host and its website on MariaDB on Linux. Which physical tool fits each server?

    Choose one answer.

    Show the answer: Question 4 of 6

    Answer: The clone plugin for the MySQL server, and mariadb-backup for the MariaDB server

    Two facts settle each server: the server family and the platform it runs on. MySQL 8.4 on Windows leaves only the clone plugin, and a MariaDB server takes mariadb-backup on Linux or Windows alike.

  5. Question 5 of 6 Which pair of jobs usually makes a logical dump the better pick, even though a physical restore is faster for a full database?

    Choose one answer.

    Show the answer: Question 5 of 6

    Answer: Restoring the definition of one dropped table, and moving a schema to an older major version

    A physical copy wins the "put a server back online" job; a logical dump wins the "bring back one table's definition" and "move this across versions" jobs. Teams keep both and run the right one for the job.

  6. Question 6 of 6 A 400 GB InnoDB database is streamed by a physical backup across a 1 Gbit/s link at an effective 100 MB/s. How many minutes does the raw byte copy take, to the nearest minute?

    Type a number.

    Show the answer: Question 6 of 6

    Answer: 67 minutes (anything from 65 to 69 counts)

    400 GB divided by 100 MB/s is 4,000 seconds, or about 66.7 minutes, so the raw copy is close to 67 minutes. The restore on the target adds the redo apply and the server start; a dump of the same data would still re-run every INSERT and rebuild every index, a cost that depends on the schema and that a restore drill measures.

Interview questions

Warm-up, for freshers: what does a physical backup copy, and what must it also capture when the server keeps writing during the copy?

A physical backup copies the data files: the InnoDB tablespaces (ibdata1, each .ibd), the undo logs, the system data dictionary and the server metadata, read while the server runs. For a hot copy the pages do not match any single moment, so the tool also copies the InnoDB redo written between the first file read and the last. On restore the server replays that redo onto the pages, rolls back uncommitted work, and the folder matches the moment the copy ended.

Three harder questions follow. Decide how you would open each answer before you read its first step.

  1. Mid to senior

    A team rebuilds a replica of a 400 GB MySQL 8.4 primary every month with Percona XtraBackup: backup, copy to the new host, prepare, copy-back, then start replication. A colleague proposes the clone plugin instead. What changes in the steps, the accounts and the replication start, and what can go wrong with the switch?

    Model answer, Pro. Model answers open with any pass; prices are in the notice on this page. First step and follow-ups

  2. Mid to senior

    Sunday's Percona XtraBackup full of a MySQL 8.4 server has incrementals from Monday and Tuesday. To restore Tuesday's state, an engineer ran a plain --prepare on the full, and now applying Monday's incremental fails. What went wrong, can the chain still be used, and what is the right sequence from the three folders to a running server?

    Model answer, Pro. First step and follow-ups

  3. Mid to staff

    A developer dropped a 30 GB InnoDB table on a 900 GB MySQL 8.4 server this morning. The only backup is last night's Percona XtraBackup full, and the team wants the table back with its rows, without restoring the whole server. Is that possible, what does it take, and which small logical artefact would have made it quick?

    Model answer, Pro. First step and follow-ups

Flashcards · 6 cards

Recall it, then check

Say the answer to yourself before you look: recalling it is what makes it stick.

  1. Why is a copy of a running server's data files inconsistent on its own, and what fixes it?

    The files are read one at a time while the server keeps writing, so they match no single moment. The tool also copies the redo written from the first file read to the last; applied on restore, it makes the folder a consistent data directory of one point in time.

  2. What does MySQL's clone plugin copy, and where does it run?

    It runs inside MySQL wherever MySQL runs, loaded from mysql_clone.so with INSTALL PLUGIN and driven by CLONE LOCAL DATA DIRECTORY or CLONE INSTANCE FROM. It copies InnoDB data only, so a MyISAM or CSV table reaches the copy with its definition but none of its rows.

  3. Which servers can Percona XtraBackup 8.4 back up?

    MySQL 8.4 and Percona Server 8.4. It is a Linux program on the database host that reads the files directly, and by default it refuses older or newer servers.

  4. Which physical backup tool fits a MariaDB server, and why not the others?

    mariadb-backup, MariaDB's own tool, forked from Percona XtraBackup 2.3.8; it runs on Linux and Windows and copies InnoDB, Aria and MyISAM. MariaDB ships no clone plugin, and XtraBackup 8.4 supports only MySQL and Percona Server 8.4.

  5. Why does a physical restore of a large database beat a dump reload?

    It writes the copied pages once, secondary indexes included: about 550 s for 220 GB at 400 MB/s. A reload parses every INSERT and rebuilds every index from the rows. Both figures stay estimates until a drill measures them.

  6. Why do teams keep a logical dump as well as physical copies?

    A dump is SQL a person can read and edit: it moves one schema or brings back one dropped table, and it crosses storage engines and major versions, which a physical copy cannot.

Key takeaways

  • A hot physical backup is the data files plus the redo written during the copy; applied on restore, the redo makes the files match one moment of the database.
  • The clone plugin runs inside MySQL wherever MySQL runs and copies InnoDB only; Percona XtraBackup is a Linux program for MySQL 8.4 and Percona Server 8.4; mariadb-backup is MariaDB’s own tool.
  • A physical restore writes the copied pages once, about 550 s for 220 GB at 400 MB/s, while a dump reload re-runs every INSERT and rebuilds every index; teams still keep a dump for selective and cross-version restores.

Terms in this lesson

clone donor
In a MySQL clone, the running server whose InnoDB data files are copied, either into a folder on the same host or to another server.
clone recipient
In a remote MySQL clone, the server that receives the donor's copy of the data files in place of its own data.
mariadb-backup
MariaDB's physical backup program, forked from Percona XtraBackup 2.3.8 and shipped with MariaDB. It copies InnoDB, Aria and MyISAM tables on Linux and Windows.
Percona XtraBackup
Percona's open-source program for physical hot copies of MySQL and Percona Server; the 8.4 line supports MySQL 8.4 and Percona Server 8.4 and runs on Linux as packages, tarballs or Docker images.

References

Report a problem with this lesson

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.