mariabackupmariabackup is a powerful tool included with MariaDB for performing physical backups of MariaDB databases. This guide covers the process of installing mariabackup, creating backups, and restoring them.
mariabackupmariabackup:
mariabackup might not be installed by default with MariaDB Server. Install it using your distribution's package manager:dnf -y install mariadb-backup
Prepare Backup Directory:
mkdir /home/mariadb_backup
Run Backup:
mariabackup to create a backup of the MariaDB databases:mariabackup --backup --target-dir /home/mariadb_backup -u root
To restore a backup, especially on a different host, follow these steps:
Prepare the Target Host:
systemctl stop mariadb
rm -rf /var/lib/mysql/*
Transfer Backup Data:
rsync, scp, or similar tools. Unpack the backup if necessary.Prepare the Backup:
mariabackup --prepare --target-dir /root/mariadb_backup
Restore the Backup:
mariabackup to copy the backup data back to the data directory:mariabackup --copy-back --target-dir /root/mariadb_backup
chown -R mysql. /var/lib/mysql
Restart MariaDB Server:
systemctl start mariadb