If you run MySQL or MariaDB in production — whether on bare metal, in Docker containers, or inside Kubernetes — you need a reliable backup strategy. The built-in mysqldump utility is fine for small databases, but it becomes unacceptably slow and locks tables once you cross a few gigabytes.
Three open-source tools dominate the self-hosted MySQL/MariaDB backup landscape: Percona XtraBackup, MyDumper, and MariaDB Backup (mariabackup). Each takes a fundamentally different approach, and the right choice depends on your database engine, size, and recovery time objectives.
This guide covers installation, Docker deployment, backup and restore procedures, and a detailed comparison to help you pick the right tool.
For related backup reading, see our general backup tools comparison and the PostgreSQL backup guide.
Why Self-Hosted MySQL Backups Matter
Database backups are your last line of defense against data loss. Whether you face hardware failure, accidental DROP TABLE statements, ransomware, or migration between servers, having tested backups is non-negotiable.
Self-hosted backup tools give you three advantages over managed cloud solutions:
- Full data sovereignty — your backups never leave your infrastructure
- No vendor lock-in — backup files are standard formats you control
- Cost predictability — no per-GB storage fees from cloud providers
For a complete backup reliability strategy, check out our backup verification and testing guide to ensure your backups are actually restorable.
How Each Tool Works
The fundamental difference lies in backup methodology: physical vs logical.
Physical Backups (Percona XtraBackup, MariaDB Backup)
Physical backup tools copy the actual database data files at the block level. They operate directly on the InnoDB/XtraDB storage engine files (.ibd, .ibdata1) without going through the SQL layer.
Key characteristics:
- Fast — limited only by disk I/O throughput
- Non-blocking — InnoDB hot backups work while the server handles queries
- Full backup only — you cannot restore individual tables from a physical backup
- Size matches the actual data on disk
Logical Backups (MyDumper)
Logical backup tools export data by executing SELECT queries against the database and writing the results as SQL statements (or other formats). MyDumper does this in parallel across multiple threads.
Key characteristics:
- Slower — goes through the SQL execution engine
- Granular — you can restore individual databases or tables
- Cross-version compatible — logical dumps can be restored on different MySQL/MariaDB versions
- Cross-engine — works with any storage engine (InnoDB, MyISAM, Aria)
Quick Comparison Table
| Feature | Percona XtraBackup | MyDumper | MariaDB Backup |
|---|---|---|---|
| Backup type | Physical (hot) | Logical (parallel) | Physical (hot) |
| Latest version | 8.4.0 | v1.0.0 | 12.2.2 (bundled) |
| GitHub stars | 1,516 | 3,119 | 7,482 (MariaDB/server) |
| Language | C++ | C | C/C++ |
| MySQL support | MySQL 8.0, 8.4 | MySQL 5.7, 8.0, 8.4 | MySQL 5.7, 8.0 |
| MariaDB support | MariaDB 10.4+ | MariaDB 10.3+ | MariaDB 10.1+ (native) |
| InnoDB | Yes | Yes | Yes |
| MyISAM | Partial (FTWRL) | Yes | Yes |
| Aria engine | No | Yes | Yes |
| Parallel backup | No (single stream) | Yes (configurable threads) | No (single stream) |
| Parallel restore | No | Yes (myloader) | No |
| Incremental backup | Yes | No | Yes |
| Point-in-time recovery | With binary logs | No | With binary logs |
| Individual table restore | No | Yes | No |
| Compressed backups | Yes (qpress, xbstream) | Yes (gzip, zstd) | Yes (qpress, xbstream) |
| Docker image | percona/percona-xtrabackup | mydumper/mydumper | Part of mariadb image |
| Best for | Large databases, minimal downtime | Selective restore, migration | MariaDB environments |
Percona XtraBackup: Installation and Usage
Percona XtraBackup is the most widely adopted physical backup tool for MySQL and MariaDB. It creates non-blocking hot backups of InnoDB and XtraDB databases by reading data pages directly from the storage engine.
Installation on Linux
| |
Docker Deployment
Percona provides an official Docker image with ~904,000 pulls:
| |
Taking a Full Backup
| |
Incremental Backups
| |
Compressed Backups
| |
MyDumper/MyLoader: Installation and Usage
MyDumper is a logical backup tool that exports MySQL data in parallel using multiple threads. It produces one file per table, making it easy to restore individual tables or databases. The companion tool, myloader, reads the backup and imports it in parallel.
Installation on Linux
| |
Docker Deployment
| |
Taking a Backup
| |
Restoring with MyLoader
| |
MariaDB Backup (mariabackup): Installation and Usage
MariaDB Backup (mariabackup) is a fork of Percona XtraBackup 2.3, maintained by the MariaDB team as part of the MariaDB Server distribution. It supports MariaDB-specific storage engines like Aria and is optimized for MariaDB’s latest features.
Installation
| |
Docker Deployment
mariabackup is bundled with the official MariaDB Docker image:
| |
Taking a Full Backup
| |
Incremental Backups
| |
Streaming to Remote Server
| |
Performance Comparison
Performance varies significantly based on database size and hardware. Here are representative benchmarks for a 50 GB InnoDB database on SSD storage:
| Operation | Percona XtraBackup | MyDumper (4 threads) | MariaDB Backup |
|---|---|---|---|
| Full backup time | ~3 min | ~12 min | ~3 min |
| Backup size | ~50 GB (raw) | ~28 GB (compressed SQL) | ~50 GB (raw) |
| Full restore time | ~5 min | ~18 min | ~5 min |
| Incremental support | Yes | No | Yes |
| Impact on server during backup | Minimal (I/O increase) | Moderate (CPU + queries) | Minimal (I/O increase) |
| Network bandwidth (streamed) | High (raw data) | Low (compressed SQL) | High (raw data) |
Key takeaway: For databases over 100 GB, physical backup tools (XtraBackup, mariabackup) are significantly faster. For databases under 10 GB where you need selective restore, MyDumper provides more flexibility.
Backup Strategy Recommendations
Small Databases (< 10 GB)
Use MyDumper with 4 threads and compression. The logical format gives you per-table restore capability, and the backup size is manageable.
| |
Medium Databases (10–100 GB)
Use Percona XtraBackup with weekly full backups and daily incrementals. This balances speed with storage efficiency.
| |
MariaDB-Only Environments
Use mariabackup. It is bundled with MariaDB, supports Aria engine, and receives updates in lockstep with the server.
Large Databases (> 100 GB)
Use Percona XtraBackup with streaming compression to a remote backup server. Incremental backups are essential to minimize I/O impact.
Which Tool Should You Choose?
| Scenario | Recommended Tool | Reason |
|---|---|---|
| MySQL 8.4, large DB | Percona XtraBackup | Fastest physical backup, incremental support |
| MariaDB production | MariaDB Backup | Native support, Aria engine compatibility |
| Need per-table restore | MyDumper | Logical backup with individual table files |
| Cross-version migration | MyDumper | Logical dump works across MySQL/MariaDB versions |
| Minimal storage budget | MyDumper | Compressed SQL is typically 40-60% of raw size |
| Point-in-time recovery | XtraBackup or mariabackup | Combine with binary log replay |
| MariaDB + MySQL mixed | Percona XtraBackup | Supports both MySQL and MariaDB |
FAQ
What is the difference between physical and logical MySQL backups?
Physical backups copy the actual database data files at the block level (.ibd, .ibdata1). They are fast and non-blocking but require the full dataset to be restored. Logical backups export data as SQL statements through the database engine, making them slower but allowing individual table restoration and cross-version compatibility.
Can I use Percona XtraBackup with MariaDB?
Yes. Percona XtraBackup 8.4 supports MariaDB 10.4 and later. However, for MariaDB-specific storage engines like Aria, you should use mariabackup instead, as XtraBackup only supports InnoDB and XtraDB engines.
Does MyDumper support incremental backups?
No. MyDumper only supports full logical backups. Each backup exports the entire selected dataset. If you need incremental backups, use Percona XtraBackup or mariabackup, both of which support incremental backup chains.
How do I automate MySQL backups with cron?
| |
Which tool is fastest for restoring a single table?
MyDumper. Since it exports each table as a separate SQL file, you can restore a single table by running myloader on just that file. Physical backup tools (XtraBackup, mariabackup) require restoring the entire database, then extracting the needed table.
Can I back up a running MySQL server without locking tables?
Yes, but only for InnoDB/XtraDB tables with physical backup tools. Percona XtraBackup and mariabackup use InnoDB’s crash recovery mechanism to create consistent hot backups without blocking writes. MyDumper briefly acquires a global read lock (FTWRL) to establish a consistent snapshot, which blocks writes for a few seconds.
How do I encrypt MySQL backups?
For XtraBackup and mariabackup, use --encrypt=AES256 with --encrypt-key or --encrypt-key-file:
| |
For MyDumper, pipe the output through GPG:
| |