Updated: 28 September 2026 · Applies to: Ubuntu 24.04, Debian 12, AlmaLinux 9 and Rocky Linux 9 (MariaDB 10.11 / MySQL 8.4)

A hot backup copies a running database without stopping it or locking tables for long. Which tool you need depends on the server:

  • MySQL 8.0 / 8.4 or Percona Server: Percona XtraBackup (8.0 or 8.4, matching your server version).
  • MariaDB (the default on AlmaLinux, Rocky, Ubuntu and Debian): mariadb-backup, MariaDB's own fork of XtraBackup. Current XtraBackup versions no longer support MariaDB.

MariaDB: mariadb-backup

dnf install mariadb-backup      # AlmaLinux / Rocky
apt install mariadb-backup      # Ubuntu / Debian
mariadb-backup --backup --target-dir=/backup/full --user=root
mariadb-backup --prepare --target-dir=/backup/full

MySQL 8.4: Percona XtraBackup 8.4

# Ubuntu / Debian
wget https://repo.percona.com/apt/percona-release_latest.generic_all.deb && apt install ./percona-release_latest.generic_all.deb
percona-release enable pxb-84-lts && apt update && apt install percona-xtrabackup-84
# AlmaLinux / Rocky
dnf install https://repo.percona.com/yum/percona-release-latest.noarch.rpm
percona-release enable pxb-84-lts && dnf install percona-xtrabackup-84

xtrabackup --backup --target-dir=/backup/full --user=root -p
xtrabackup --prepare --target-dir=/backup/full

For MySQL 8.0 use pxb-80 and percona-xtrabackup-80 instead.

Restore

  1. Stop the database: systemctl stop mariadb (or mysqld / mysql).
  2. Move the old data directory away: mv /var/lib/mysql /var/lib/mysql.old && mkdir /var/lib/mysql.
  3. Copy the prepared backup back: mariadb-backup --copy-back --target-dir=/backup/full (or xtrabackup --copy-back).
  4. Fix ownership and start: chown -R mysql:mysql /var/lib/mysql && systemctl start mariadb. On AlmaLinux/Rocky also run restorecon -R /var/lib/mysql.

Note: A backup must be prepared before it can be restored. Test restores on another server regularly. For small databases, mariadb-dump --single-transaction is simpler and portable between versions.

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Managed cPanel VPS

cPanel included; we handle updates, security and monitoring.

Server management

on-demand administration, hardening, migrations and monitoring.

Was this answer helpful?

Still stuck? Open a ticket