Hello, again!
This is just a small blog post on how to backup and restore a MariaDB server, without using MysqlDump, but by directly copying the files in /var/lib/mysql.
Backing up
First of course we need to shutdown mariadb.
Copying files:
Restoring
When putting things back, things start to go wrong1.
Copying the files to a new host, causes this:
So, if the below code works, than SELinux is causing the issue:
Now you added mysql_t to permissive, as shown by the below printout:
Builtin Permissive Types
Customized Permissive Types
mysqld_t
Turning it back to enforcing, means running:
libsemanage.semanage_direct_remove_key: Removing last permissive_mysqld_t module (no other permissive_mysqld_t module exists at another priority).
We need to relabel the new /var/lib/mysql directory:
Checking the current file contexts:
unconfined_u:object_r:mysqld_db_t:s0 /var/lib/mysql
MariaBackup
I need to check out MariaBackup2 3, as a better solution for creating backups compared to mysqldump.
References
- [1] Security-Enhanced Linux with MariaDB
- https://mariadb.com/kb/en/selinux/
- [2] Backing up and restoring databases
- https://mariadb.com/kb/en/backing-up-and-restoring-databases/
- [3] MariaBackup
- https://mariadb.com/kb/en/mariabackup/
- [4] Full Backup and Restore with MariaBackup
- https://mariadb.com/kb/en/full-backup-and-restore-with-mariabackup/