Not long ago I had to restore a zimbra server 8.8.5 machine full of mailboxes and emails onto a new virtual machine. For some reason I didn't have time to track down, the soap process that handles almost every zimbra server operation kept returning a 503 error, making the server unusable.
At that point I had no choice but to restore everything onto a new machine with a freshly installed zimbra server 8.8.5.
The main zimbra server folders, the ones holding the data, are:
bash
/opt/zimbra/store/ #contiene tutte le email delle caselle/opt/zimbra/db/ #è il database mariadb /opt/zimbra/index/ #contiene l'index lucene delle mail/opt/zimbra/conf/ #contiene tutte le configurazioni di zimbra e le informazioni di ldap
Restore steps
Let's call ZimbraOld the "broken" zimbra machine and ZimbraNew the new machine with the freshly installed zimbra server.
To avoid any installation issues, before installing the ZimbraNew machine you need to stop all services on the ZimbraOld machine and change its ip address.
The command to stop all services is
bash
su - zimbra
zmcontrol stop
Let's also check that no orphan processes are still running with
bash
ps-aux|grep zimbra
Now we can install ZimbraNew on a new machine that has ZimbraOld's old ip.
Once the ZimbraNew installation is done and we've checked that everything works properly, we can move on to transferring the data.
So on the ZimbraNew machine we stop all zimbra services.
bash
su - zimbra
zmcontrol stop
From the ZimbraOld machine we set up a key-based ssh connection from the root user to the root user of ZimbraNew
bash
# se non abbiamo ancora creato la nostra chiavessh-keygen -t rsa
# copiamo la chiave conssh-copy-id -i ~/.ssh/id_rsa root@ZimbraNew
Once that's done, we can use rsync commands without worrying about typing the password every time.
So from ZimbraOld we run the following commands
bash
# Copiamo file e databasersync-a--delete /opt/zimbra/store/ root@ZimbraNew:/opt/zimbra/store
rsync-a--delete /opt/zimbra/db/ root@ZimbraNew:/opt/zimbra/db
rsync-a--delete /opt/zimbra/index/ root@ ZimbraNew:/opt/zimbra/index
# Copiamo le configurazionirsync-av--delete--exclude=data.mdb /opt/zimbra/data/ root@ZimbraNew:/opt/zimbra/data
It's very important to exclude the data.mdb file from this copy, since it's a sparsebundle. If you try to copy it (like I did the first time) it will fill up the destination disk.
cd /opt/zimbra/backup/
chmod777 archivioldap.tar.gz
tar-zxvf archivioldap.tar.gz
su - zimbra
cd ldap/mdb/db/
mv data.mdb ../../../../data/ldap/mdb/db/
With all that done, it should be enough to run from ZimbraNew (as the zimbra user)
bash
zmcontrol start
Et voilà! The new server will hold all the data of the old one!.
Possible problems with self signed certificates
If you run into certificate problems (if you have self signed certificates) follow these steps:
bash
/opt/zimbra/bin/zmcertmgr createca -new/opt/zimbra/bin/zmcertmgr deployca
#impostiamo a 10 anni circa la scadenze/opt/zimbra/bin/zmcertmgr createcrt -new-days3650
/opt/zimbra/bin/zmcertmgr deploycrt self
/opt/zimbra/bin/zmcertmgr viewdeployedcrt
su - zimbra
zmcontrol restart