You can use the tool Mariadb-backup (formerly called mariabackup) to backup and restore your MariaDB database. For more information, see https://mariadb.com/docs/server/server-usage/backup-and-restore/mariadb-backup.
You can use either the --copy-back or --move-back options to restore your backup. The --copy-back option allows you to keep your original backup files and copies the new backup files to a different location. The --move-back option moves the backup from the target directory to the data directory.
Backup your database by running the following command:
$ mariabackup --backup \
--target-dir=/var/mariadb/backup/ \
--encrypted-backup --user=mariabackup --password=mypassword\
Note: Ensure that the target directory is empty before you begin.
After the backup is complete, prepare the backup for restoration by running the following command:
$ mariabackup --prepare \
--use-memory=124M --target-dir=/var/mariadb/backup/
Note: The
--use-memorycommand defines the buffer pool size that is used during the preparation stage. If you see errors while preparing a backup, try increasing the buffer pool size.Use the
--copy-backor--movebackcommands to restore the database as follows:Stop the MariaDB service using the following command:
systemctl stop mariadbEnsure that the directory where you plan to restore the backup is empty.
Run the Mariadb-backup command with your preferred option. For example:
$ mariabackup --copy-back \
--target-dir=/var/mariadb/backup/
If necessary, update the file permissions using the
chown -R mysql:mysql /var/lib/mysql/command.Start the MariaDB service using the
systemctl start mariadbcommand.