Zimbra Next Generation Modules/DR/Disaster Recovery - MariaDB data loss or corruption: Difference between revisions

 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
WORK IN PROGRESS
#REDIRECT [[Zimbra_NG_Modules/DR/Disaster_Recovery_-_MariaDB_data_loss_or_corruption]]
 
=Introduction=
This step-by-step guide contains all the information needed to restore lost or corrupted MariaDB data. It applies to both single-server and multi-server infrastructures with only a single MariaDB server.
 
=Step 1: Database re-initialisation=
The first step in order to restore the database to a consistent state is to re-initialise the database itself to its initial state.
 
To do this:
* Stop all services by running <code>zmcontrol stop</code> as the zimbra user.
* Rename *or* empty the current Database folder - default <code>/opt/zimbra/db/data/</code>
** Rename: <code>mv /opt/zimbra/db/data/ /opt/zimbra/db/data_old/</code>
** Empty: <code>rm -rf /opt/zimbra/db/data/*</code>
* After cleaning up the database, re-initialise it by running <code>/opt/zimbra/libexec/zmmyinit</code> as the zimbra user:
<pre>
* Creating required directories
* Generating mysql config /opt/zimbra/conf/my.cnf
* Creating database in /opt/zimbra/db/data
* Starting mysql server
* Loading schema /opt/zimbra/db/db.sql
* Loading version from /opt/zimbra/db/versions-init.sql
* Loading version from /opt/zimbra/db/backup-version-init.sql
* Setting random passwd for mysql root user in zimbra localconfig
* Setting random passwd for mysql zimbra user in zimbra localconfig
* Changing mysql root user password
* Changing mysql zimbra user password
* Changed zimbra mysql user password
</pre>
Database passwords as well as mailbox IDs will not be changed.
* After re-initialising the database, start all services by running <code>zmcontrol start</code> as the zimbra user
 
If everything succeeded, after all services are initialised you should see that mailboxgroups have been created anew:
<pre>
ls -la /opt/zimbra/db/data/
total 1099868
drwxr-x--- 16 zimbra zimbra      4096 Aug 28 12:09 .
drwxrwxr-x  3 zimbra zimbra      4096 Aug 25 18:03 ..
drwx------  2 zimbra zimbra      4096 Aug 28 12:09 chat
-rw-rw----  1 zimbra zimbra 524288000 Aug 28 12:11 ib_logfile0
-rw-rw----  1 zimbra zimbra 524288000 Aug 28 12:03 ib_logfile1
-rw-rw----  1 zimbra zimbra  77594624 Aug 28 12:11 ibdata1
drwx------  2 zimbra zimbra      4096 Aug 28 12:09 mboxgroup1
drwx------  2 zimbra zimbra      4096 Aug 28 12:09 mboxgroup2
drwx------  2 zimbra zimbra      4096 Aug 28 12:09 mboxgroup3
drwx------  2 zimbra zimbra      4096 Aug 28 12:09 mboxgroup4
drwx------  2 zimbra zimbra      4096 Aug 28 12:09 mboxgroup5
drwx------  2 zimbra zimbra      4096 Aug 28 12:09 mboxgroup6
drwx------  2 zimbra zimbra      4096 Aug 28 12:09 mboxgroup7
drwx------  2 zimbra zimbra      4096 Aug 28 12:09 mboxgroup8
drwx------  2 zimbra zimbra      4096 Aug 28 12:09 mboxgroup9
-rw-rw----  1 zimbra zimbra        0 Aug 28 12:03 multi-master.info
drwx------  2 zimbra zimbra      4096 Aug 28 12:03 mysql
drwx------  2 zimbra zimbra      4096 Aug 28 12:03 performance_schema
-rw-rw----  1 zimbra zimbra    24576 Aug 28 12:03 tc.log
drwx------  2 zimbra zimbra      4096 Aug 28 12:03 test
drwx------  2 zimbra zimbra      4096 Aug 28 12:03 zimbra
</pre>
=Step 2: Data Restore=
At this point of the process the database is up and running, but mostly empty. You can check this by looking at any mailbox's content using zmprov:
<pre>
zmmailbox -z -m rick@domain.local gaf
        Id  View      Unread  Msg Count  Path
----------  ----  ----------  ----------  ----------
        1  unkn          0          0  /
        16  docu          0          0  /Briefcase
        10  appo          0          0  /Calendar
        14  mess          0          0  /Chats
        7  cont          0          0  /Contacts
        6  mess          0          0  /Drafts
        13  cont          0          0  /Emailed Contacts
        2  mess          0          0  /Inbox
        4  mess          0          0  /Junk
        5  mess          0          0  /Sent
        15  task          0          0  /Tasks
        3  unkn          0          0  /Trash
</pre>
To restore the data, the doExternalRestore feature of Backup NG will be used.
 
* To start the restore, simply start a complete External Restore by running <code>zxsuite backup doExternalRestore [your backup path here]</code> as the zimbra user
** e.g. if your backup path is /opt/zimbra/backup/ then run <code>zxsuite backup doExternalRestore /opt/zimbra/backup/</code>
* Once the restore has started, you'll find an "External Restore Started" notification in the "Notifications" section of the NG Adminitration Zimlet.
** That notification, along with the output of the command, will include the "Operation ID" of the restore - make sure to keep it at hand.
* To verify the progress of the restore, you can check the dedicated restore log found in <code>/opt/zimbra/logs/</code> called <code>op_ExternalRestore_[operation ID].log</code>
* After  the External Restore has been completed, you will receive an "External Restore Completed" notification.
** You can now verify that data has been restored by checking the content of a mailbox with zmprov:
<pre>
zmmailbox -z -m rick@domain.local gaf
        Id  View      Unread  Msg Count  Path
----------  ----  ----------  ----------  ----------
        1  unkn          0          0  /
        16  docu          0          0  /Briefcase
        10  appo          0          0  /Calendar
        14  mess          0          0  /Chats
        7  cont          0          0  /Contacts
        6  mess          0          0  /Drafts
        13  cont          0          0  /Emailed Contacts
        2  mess        5159        6258  /Inbox
        4  mess          0          0  /Junk
        5  mess          0        118  /Sent
        15  task          0          0  /Tasks
        3  unkn          28          29  /Trash
</pre>
* In several cases, one run of the External Restore is not enough to restore all items, so run the very same restore command again (this will have a new Operation ID and a new restore log).
* Once the second restore is completed, all data will have been restored.
 
=Step 3: Volume Deduplication=

Latest revision as of 12:16, 29 November 2017

Jump to: navigation, search