Operations
Back up, restore, and verify MariaDB with the mariadb-backup tool, then add a replica so one failed server doesn't take your application down.
It's late on a Friday when the disk under the shop's database server fails. The application is down, customers see errors, and the only question that matters is whether the data comes back. If a mariadb-backup job ran last night, the answer is yes, up to the moment that backup ran. If nobody has ever restored one of those backups, the answer is a hope.
The mariadb-backup tool copies the data files while MariaDB Server keeps running, so the nightly backup never takes the shop offline. A restore copies those files back instead of replaying every SQL statement, which keeps recovery fast even when the tables are large. The only time the server has to stop is while the files go back into place.
Back Up and Restore
Run these steps on a test server before the Friday that needs them. A restore you have practiced once takes minutes. A restore you are reading about for the first time during an outage takes much longer.
Take a Backup
The mariadb-backup tool connects to MariaDB Server as a user of its own, so create that user with the privileges the tool needs. Then point the tool at an empty target directory. The tool creates the directory itself, but its parent directory must already exist. Run the tool with sudo, because it reads the data files that belong to the mysql user.
The mariadb-backup overview lists the extra privileges that some options need, such as --galera-info.
Prepare and Restore
The tool copied the data files at slightly different moments while the shop kept taking writes, so the prepare step makes them consistent first. Then stop the server, move the damaged data directory (/var/lib/mysql by default) out of the way, copy the backup in, and give the files to the mysql user that MariaDB Server runs as.
Prepare the backup with the same version of the mariadb-backup tool that took it. Full backup and restore covers the --move-back alternative and restoring with rsync.
Verify the Restore
Start the server and count the rows in a table whose contents you know. The shop.products table from the landing page should return 3, the same count it had when the backup ran.
When the counts match, the application can reconnect, and you can remove the old data directory at /var/lib/mysql.old. To keep nightly backups small between full copies, see incremental backup and restore.
The shop is back, with everything up to last night's backup. Orders placed after that backup ran are the part a single server can't give back.
Add a Replica
A replica, a second server that keeps its own copy of the data, covers both the outage and the lost orders. It applies each change from the primary server's binary log, usually within seconds, so a failed disk on the primary costs only the changes the replica hadn't received yet, not a day of orders. MariaDB MaxScale sits between the application and the servers, sends writes to the primary, and sends reads to the replica, which is also where the shop starts getting faster. With automatic failover turned on in its monitor, MaxScale also promotes the replica when the primary fails. The MariaDB Platform page shows how these pieces fit together.
Keep Going
This page is: Copyright © 2026 MariaDB. All rights reserved.
Last updated
Was this helpful?

