Backup MySQL/MariaDB to SPFS
In this blog post we're explaining different methods of backing up and restoring your MariaDB/MySQL with standard tools direct to a Spectrum Protect environment using SPFS.
Before your start make sure you have SPFS installed and configured. If you need help to configure SPFS please see our blog Installing SPFS on Linux
Make sure you have following i
Path to MySQL/MariaDB configuration files
MySQL/MariaDB port number
See port entry in MySQL/MariaDB config file, default port is 3306
ID and Password for privileged MySQL/MariaDB user
Export your Database User as $DB_USER
and export user password as $DB_PASSWORD
Path to SPFS Mountpoint
MySQL and MariaDB have a set of tools build in and here do we show how you can use them together with SPFS to backup and restore your databases.
To backup a single database with mysqldump you can use following command
<DATABASE NAME> > /<SPFS MOUNTPOINT>/<DATABASE_NAME>.dump
If you want to backup all databases at the same time you can use following command.
for DB in $(mysql -e 'show databases' -s --skip-column-names
mysqldump $DB_NAME > "/backup/$DB.dump"
if [ $? –ne 0]; RC=$(( $RC + 1 ))
When you need to restore a database from mysqldump you can do following command
$DB_NAME < /backup/$DB_NAME.dump
To backup all data at the same time with mysqlbackup you can use following command
When you need to restore you will restore everything when using mysqlbackup
In Ubuntu and Debian you have the backup tool called mydumper and to backup your database you can use following command
When you want to restore a database with mydumper you can do that easy by following command.
I hope you found this blog post useful and I wish you a great summer!