How to properly backup Zimbra?

Discuss your pilot or production implementation with other Zimbra admins or our engineers.
mateusscheper
Posts: 11
Joined: Tue May 29, 2018 12:49 pm

How to properly backup Zimbra?

Postby mateusscheper » Fri Jan 11, 2019 3:55 pm

Currently I'm copying via rdiff-backup the Zimbra directory (/opt/zimbra) to another server. But is this a good way to back it up? I'm thinking on using Bacula instead, but I'm not sure.


axslingr
Advanced member
Advanced member
Posts: 101
Joined: Sat Sep 13, 2014 2:20 am
ZCS/ZD Version: Release 8.8.9.GA.3019.UBUNTU14.64

Re: How to properly backup Zimbra?

Postby axslingr » Fri Jan 11, 2019 10:46 pm

Here's a little script I use. Nothing fancy but gets the job done. Modify for your environment and test before using. In the event of disaster, just restore /opt/zimbra and copy data.mdb back to /opt/zimbra/data/ldap/mdb/db and set permissions.

Code: Select all

#!/bin/bash

#Rsync Zimbra while still online...reduces downtime
rsync -avHK --delete --exclude 'data.mdb' /opt/zimbra /some/backup/location/

#Backup ldap database
#This line is necessary after the first database backup because mdb_copy won't delete existing file
mv /some/backup/location/ldap/data.mdb /some/backup/location/ldap/data.mdb.bak

/opt/zimbra/common/bin/mdb_copy /opt/zimbra/data/ldap/mdb/db /some/backup/location/ldap

#Stop Zimbra Services
su - zimbra -c 'zmcontrol stop'

sleep 30

#Rsync again while zimbra services are stopped
rsync -avHK --delete --exclude 'data.mdb' /opt/zimbra /some/backup/location/

#Start zimbra services
su - zimbra -c 'zmcontrol start'

exit
mateusscheper
Posts: 11
Joined: Tue May 29, 2018 12:49 pm

Re: How to properly backup Zimbra?

Postby mateusscheper » Mon Jan 14, 2019 11:04 am

axslingr wrote:Here's a little script I use. Nothing fancy but gets the job done. Modify for your environment and test before using. In the event of disaster, just restore /opt/zimbra and copy data.mdb back to /opt/zimbra/data/ldap/mdb/db and set permissions.

Code: Select all

#!/bin/bash

#Rsync Zimbra while still online...reduces downtime
rsync -avHK --delete --exclude 'data.mdb' /opt/zimbra /some/backup/location/

#Backup ldap database
#This line is necessary after the first database backup because mdb_copy won't delete existing file
mv /some/backup/location/ldap/data.mdb /some/backup/location/ldap/data.mdb.bak

/opt/zimbra/common/bin/mdb_copy /opt/zimbra/data/ldap/mdb/db /some/backup/location/ldap

#Stop Zimbra Services
su - zimbra -c 'zmcontrol stop'

sleep 30

#Rsync again while zimbra services are stopped
rsync -avHK --delete --exclude 'data.mdb' /opt/zimbra /some/backup/location/

#Start zimbra services
su - zimbra -c 'zmcontrol start'

exit


Thank you very much for your help. Your script seems great.

Just to make sure: mdb_copy makes a file with only 9,3M out of 80G. Is this correct? According to this link, it's ok, but I'm not sure how to see my mdb size.

BTW, why do you rsync two times?
spectre.nl
Posts: 2
Joined: Sun Jan 24, 2016 4:22 pm

Re: How to properly backup Zimbra?

Postby spectre.nl » Mon Jan 14, 2019 12:38 pm

Because the open source version lacks the backup I found this on github :

https://github.com/Zmbackup/zmbackup
A reliable software written in Python to help you in your daily task to backup and restore mails and accounts from Zimbra Open Source Email Platform.

works very well
axslingr
Advanced member
Advanced member
Posts: 101
Joined: Sat Sep 13, 2014 2:20 am
ZCS/ZD Version: Release 8.8.9.GA.3019.UBUNTU14.64

Re: How to properly backup Zimbra?

Postby axslingr » Mon Jan 14, 2019 12:57 pm

mateusscheper wrote:
Just to make sure: mdb_copy makes a file with only 9,3M out of 80G. Is this correct? According to this link, it's ok, but I'm not sure how to see my mdb size.



That's correct.

Code: Select all

du -hs /opt/zimbra/data/ldap/mdb/db


This will show you the real size.

BTW, why do you rsync two times?


The first time is while Zimbra is still running, to get the majority of the changes and reduce the time Zimbra is offline during the second rsync.

Lance

Return to “Administrators”

Who is online

Users browsing this forum: No registered users and 26 guests