MariaDB Incremental Backup
Preliminary support for for the MariaDB command “mariabackup” has been added to MAS. Support consists of four processes:
The mariabackup command is only supported under Linux and Windows. Note that the functionality of the tool is evolving; the MAS processes support MariaDB 10.2 and later. The existing functionality only supports full backups and restores.
The two backup commands may be run against a live database; it does not need to be shut down.
The vendita.mariadb.rdbms.full_backup command requires a root (or other privileged account) SSH from which the mariabackup command will be run, a privileged database login and password from which the backup will be made, and the name of a directory which will store the backup.
The vendita.mariadb.rdbms.incremental_backup command is similar to the full_backup command discussed above, but it takes as an additional parameter the name of a directory that contains a previously created full backup. The incremental backup will be relative to that data.
All restores must be performed after the MariaDB database has been shut down. On most distros of Linux, this will be done with a command similar to:
systemctl stop mysql
This command may vary between installations.
Note that the database storage directory (by default “/var/lib/mysql”) will be removed as part of the restore process.
Once the restore has been completed, the ownership of the database storage directory will likely need to be corrected (after the restore, it will be owned by the user performing the restore...normally the root user). The typical command for this is:
chown -R mysql.mysql /var/lib/mysql
As with the shutdown and startup commands, this may vary by OS and installation; this is simply a common default. It is also possible that more permissions or security adjustments may be required, for example with selinux. This is highly site dependent. After the restore has been completed and any permissions adjustments made, the database may be restarted (typically “systemctl start mysql” or equivalent).
The vendita.mariadb.rdbms.full_restore command is used to perform a full mariabackup restore. The parameters are similar to the backup command: a privileged (typically root) shell account, database user and password, and the name of a directory containing a full mariabackup backup.
The vendita.mariadb.rdbms.incremental_restore command will execute a database restore from a series of up to six incremental backup on top of a full backup. It requires that a privileged shell account be specified, the database user and password, the directory name of a full backup, and the names of up to six incremental backups listed from #1 (the oldest) to #6 (the newest).
The backup process is fairly straight-forward; the “mariabackup” command isinvoked with the proper parameters. Restores are a little more complicated:
- Each backup directory must be “prepared” with one invocation of mariabackup
- The database storage directory is determined by invoking mysqld and parsing the output
- The database storage directory is removed
- Each backup directory is then restored in order of oldest (full) to newest (incremental #6)
The only good source of information I’ve been able to find on mariabackup is the actual MariaDB documentation found at https://mariadb.com/kb/en/library/mariabackup/