Difference between revisions of "MariaDB Backup and Restore"

m
Line 2: Line 2:
 
__FORCETOC__
 
__FORCETOC__
 
<div class="col-md-12 ibox-content">
 
<div class="col-md-12 ibox-content">
 +
<hr>
 
==MariaDB Backup and Restore==
 
==MariaDB Backup and Restore==
{{KB|{{Unsupported}}|{{ZCS 8.8}}|{{ZCS 9.0}}|}}{{WIP}}
+
{{KB|{{WIP}}|{{ZCS 8.8}}|{{ZCS 9.0}}|}}  
 +
<hr>
 +
 
  
 
==Overview==
 
==Overview==

Revision as of 23:54, 17 September 2020


MariaDB Backup and Restore

   KB 24154        Last updated on 2020-09-17  




0.00
(0 votes)


Overview

Backup

Full Backup (Base Backup)

mkdir -p /opt/db_backup/backup
mariabackup --backup -S /opt/zimbra/data/tmp/mysql/mysql.sock --target-dir=/opt/db_backup/backup --user=root --password=`zmlocalconfig -s -m nokey mysql_root_password`


Incremental Backup

1st Incremental backup:

mkdir -p /opt/db_backup/inc1
mariabackup --backup -S /opt/zimbra/data/tmp/mysql/mysql.sock --target-dir=/opt/db_backup/inc1/ --incremental-basedir=/opt/db_backup/backup/ --user=root --password=`zmlocalconfig -s -m nokey mysql_root_password`

2nd Incremental backup:

mkdir -p /opt/db_backup/inc2 
mariabackup --backup -S /opt/zimbra/data/tmp/mysql/mysql.sock --target-dir=/opt/db_backup/inc2/ --incremental-basedir=/opt/db_backup/inc1/ --user=root --password=`zmlocalconfig -s -m nokey mysql_root_password`

3rdIncremental backup:

mkdir -p /opt/db_backup/inc3 
mariabackup --backup -S /opt/zimbra/data/tmp/mysql/mysql.sock --target-dir=/opt/db_backup/inc3/ --incremental-basedir=/opt/db_backup/inc2/ --user=root --password=`zmlocalconfig -s -m nokey mysql_root_password`


Restore

Prepare Backup for Restore

Prepare Base Backup
mariabackup --prepare --apply-log-only -S /opt/zimbra/data/tmp/mysql/mysql.sock --target-dir=/opt/db_backup/backup
Apply Incremental Backup to Base Backup
mariabackup --prepare --apply-log-only -S /opt/zimbra/data/tmp/mysql/mysql.sock --target-dir=/opt/db_backup/backup --incremental-dir=/opt/db_backup/inc1/  
mariabackup --prepare --apply-log-only -S /opt/zimbra/data/tmp/mysql/mysql.sock --target-dir=/opt/db_backup/backup --incremental-dir=/opt/db_backup/inc2/  
mariabackup --prepare --apply-log-only -S /opt/zimbra/data/tmp/mysql/mysql.sock --target-dir=/opt/db_backup/backup --incremental-dir=/opt/db_backup/inc3/  


Restore Prepared Backup

1) Stop MariaDB service.

mysql.server stop


2) Clear existing datadir (/opt/zimbra/db/data) directory. [ensure that the datadir is empty]

mv /opt/zimbra/db/data /opt/zimbra/db/data.OLD 
mkdir /opt/zimbra/db/data 


3) Restore the prepared backup.

mariabackup --copy-back -S /opt/zimbra/data/tmp/mysql/mysql.sock --target-dir=/opt/db_backup/backup 
OR
mariabackup --copy-back -S /opt/zimbra/data/tmp/mysql/mysql.sock --target-dir=/opt/db_backup/backup --datadir /opt/zimbra/db/data 


4) Fix the permissions.

chown -R zimbra:zimbra /opt/zimbra/db/data  


5) Start MariaDB service.

mysql.server start
Jump to: navigation, search