MariaDB 10.1 introduced a new backup feature called Mariabackup. Mariabackup is an open-source tool provided by MariaDB for performing physical online backups of InnoDB, Aria, and MyISAM tables. It also enabled “hot online” backups for InnoDB tables. Mariabackup doesn’t only back up databases, it also backs up many different files to perform its backup and restore operations. To get started with backing up and restoring MariaDB data, follow the steps below:

Install Mariabackup

When you install the MariaDB database server, its backup tool isn’t installed automatically. If you want to implement and backup and restore process with MariaDB, you’ll want to install its backup tool. Run the commands below to install it on Ubuntu. That should install the tool on Ubuntu.

Backing up MariaDB

Now that the tool is installed, you can run it with different options to perform a full backup and restore of MariaDB databases and data files on Ubuntu and other Linux systems. First, run the commands below to create a backup directory to store MariaDB backup content. This should create a backup folder in your home directory: /home//mariadb_backup. After creating the backup folder above, simply run the commands below to create a live backup and store it in the folder above. When you run the commands above, it should complete with a success message. Run the commands below to list the content of the backup folder. It should list something similar to the lines below: That’s it! You have successfully backup MariaDB.

Restoring MariaDB

After creating a backup copy above, you can create a zipped or tarred copy of the folder and export it to another server using Rsync or SCP if you’re migrating. If you’re exporting the database to another server, simply run the commands below to create an archive. You’ll want to use sudo since the database content was added using sudo. Now send backup data over to a remote location using Rsync or SCP. On the remote host, run the commands below to extract the archive. Next, stop the MariaDB service and delete any existing MariaDB data. Next, prepare the backup file for restoration. When you run the commands above, it should give you a success message as shown below: After preparing the database for restoration, simply run the commands below to restore. When the command above is completed, it should display a success message similar to the one below: Next, run the commands to give MySQL service control of the mysql folder. Finally, start the MariaDB service. That should do it! Conclusion: This post showed you how to back up and restore MariaDB databases and data using the Mariabackup tool. If you find any error above, please use the form below to report. You may also like the post below: