MariaDB Backup and Restore
Physical backups with mariabackup, logical dumps, and restoring into a Galera cluster.
MariaDB's physical backup tool is mariabackup, a fork of Percona XtraBackup adapted to MariaDB's
InnoDB variant.
Physical backup
mariabackup --backup \
--target-dir=/backups/base \
--user=backup --password=… \
--parallel=4
# Prepare makes the copy consistent. Required before any restore.
mariabackup --prepare --target-dir=/backups/base
# Incremental against a previous backup.
mariabackup --backup --target-dir=/backups/inc1 \
--incremental-basedir=/backups/baseRestore into a stopped server with an empty data directory:
systemctl stop mariadb
rm -rf /var/lib/mysql/*
mariabackup --copy-back --target-dir=/backups/base
chown -R mysql:mysql /var/lib/mysql
systemctl start mariadbLogical backup
mariadb-dump --single-transaction --master-data=2 \
--routines --events --triggers \
--databases shop | zstd -T0 > /backups/shop.sql.zst--master-data=2 records the binlog coordinates as a comment, which is what a point-in-time
recovery or a new replica needs.
Point-in-time recovery
Restore the last physical backup, then replay binlogs from its recorded position:
mariadb-binlog --start-position=1234 \
--stop-datetime="2026-07-30 14:22:00" \
mariadb-bin.000042 > /tmp/replay.sql
mariadb < /tmp/replay.sqlWith GTIDs, --start-position accepts a GTID, which is more robust than a file offset across a
failover.
Restoring into a Galera cluster
Procedure:
- Stop all nodes.
- Restore and prepare the backup on the intended bootstrap node.
- Remove
grastate.daton that node so it starts a fresh cluster state, or setsafe_to_bootstrapappropriately. - Start it with
galera_new_cluster. - Start remaining nodes; they take an SST from the bootstrap node.
- Verify
wsrep_cluster_sizematches the expected node count and every node reportsSynced.
Verification
Restore into an isolated instance on a schedule, check row counts and one business invariant, and record the elapsed time against the recovery time objective. See Restore Testing.