Protecting MariaDB using mariabackup
with IBM Spectrum Protect
There are several ways to protect MariaDB databases, where we are going to focus on using the mariabackup tool.

1.Install the IBM Spectrum Protect Client API
# rpm -ivh gsk*.rpm
# rpm –ivh *api*.rpm
# dpkg -i gsk*.deb
# dpkg –i *api*.deb
2. Install the SPFS software
# rpm -ivh spfs*.rpm
# rpm –ivh spictera*.rpm
# dpkg -i spfs*.deb
# dpkg –i spictera*.deb
3. Configure the Spectrum Protect client
# vi /opt/tivoli/tsm/client/api/bin64/dsm.sys
SERVERNAME spfs
TCPSERVERADDRESS tsm.backupserver.com
ERRORLOGNAME /var/log/dsmerror_spfs.log
4. Register the node on the backup server
TSM> REGISTER NODE SPFS secret DOMAIN=SPFS
5. Configure the SPFS file system
5.1 Create option file
# echo SERVERNAME spfs > /etc/spfs/dsm.opt
5.2 set initial password
# setpassword /etc/spfs/TSM.PWD <<< secret
5.3 Create spfs configuration
# vi /etc/spfs/spfs.opt
MOUNTPOINT /backup
NODENAME spfs
NODEPWDFILE /etc/spfs/TSM.PWD
OPTIONFILE /etc/spfs/dsm.opt
6. mounting the SPFS file system
# mkdir /backup
# mount.spfs /backup
You are now ready to start using Spectrum Protect as a file system, storing and retrieving backup data of MariaDB
Full Backup of MariaDB
# mariadb-backup — backup — user=backup— password=secret — parallel=10 — stream=xbstream > /backup/bu.stream
It is also possible to use the command, if you want each database file to be separate
# mariabackup --user=backup --password=secretpwd \
-- parallel=6 --backup --target-dir=/backup/$(date +%Y-%m-%d.%H:%M:%S)
Incremental backup of MariaDB
# mariabackup --prepare --target-dir=/backup/2021-12-27.00:10:00 --incremental-dir=/backup/$(date +%Y-%m-%d.%H:%M:%S)
Restoring from backup
Step 1: stop MariaDB
# systemctl stop mariadb
Step 2: remove data files
# cd /var/lib/mysql
# rm -rf *
Step 3: restore data files
# mbstream -x < /backup/bu.stream
Or if you used the second example, than one can use
# mariabackup --copy-back --target-dir=/backup/201-12-27.00:10:00 --parallel=8
Step 4: prepare
# mariabackup --prepare --target-dir=/var/lib/mysql
Step 5: change ownerships of files
# chown -R mysql.mysql /var/lib/mysql
Step 6: start MariaDB
# systemctl start mariadb
If you want to restore from an older version, than one can change step 3 to the version of interest. Eg previous backup version
# mbstream -x < “/backup/bu.stream(-1)”