How To Restore MariaDB backup

2023-08-04 | 101 words

This is a very fine-tuned procedure to restore MariaDB backups. Make sure you restore the DB to the same version of MariaDB.

# Unzip and then use mbstream utility to extract data
cd /home/backup;
gunzip -c database.gz | mbstream -x;

# Remove everything from mysql dir
cd /var/lib/mysql;
rm -r *;

# Prepare and copy back to mysql dir
mariabackup --prepare --target-dir=/home/backup;
mariabackup --copy-back --target-dir=/home/backup;

# Change permissions
chown -R mysql:mysql /var/lib/mysql/;

# Restart system (or mysql server)
service mysqld restart

# Login as root to mysql then allow login from everywhere
GRANT ALL ON *.* to UZIVATEL@'%' IDENTIFIED BY 'HESLO';