Difference between revisions of "MariaDB Backup and Restore"

(One intermediate revision by the same user not shown)
Line 3: Line 3:
<div class="col-md-12 ibox-content">
<div class="col-md-12 ibox-content">
==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}}|}}  
Line 70: Line 73:
5) Start MariaDB service.  
5) Start MariaDB service.  
  mysql.server start
  mysql.server start
{| class="wikitable" style="background-color:#d0f0c0;" cellpadding="10"
|'''Submitted by''':  Heera Singh Koranga
{{Article Footer|ZCS 9.0,8.8|2020-09-17}}

Latest revision as of 00:00, 18 September 2020

MariaDB Backup and Restore

   KB 24154        Last updated on 2020-09-18  

(0 votes)



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`


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 
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

Submitted by: Heera Singh Koranga
Verified Against: ZCS 9.0,8.8 Date Created: 2020-09-17
Article ID: https://wiki.zimbra.com/index.php?title=MariaDB_Backup_and_Restore Date Modified: 2020-09-18

Try Zimbra

Try Zimbra Collaboration with a 60-day free trial.
Get it now »

Want to get involved?

You can contribute in the Community, Wiki, Code, or development of Zimlets.
Find out more. »

Looking for a Video?

Visit our YouTube channel to get the latest webinars, technology news, product overviews, and so much more.
Go to the YouTube channel »

Jump to: navigation, search