How to Migrate from Zimbra to Carbonio & Zimbra to Zimbra (different operating systems)

Recently I discovered a really useful script that allows you to migrate from one version of Zimbra to another and this migration can happen between different operating systems too. So it could be 2 of the same versions of Zimbra but you want to upgrade the operating system; for instance you are on Centos 6 and want to upgrade to Rocky Linux 8.

There are 2 scripts involved:-

(1) export_zimbra.sh
(2) import_zimbra.sh

You can create a directory called /opt/scripts/ and put these scripts there; export_zimbra.sh is the script which would export all of the content and settings except mailbox content, such as calendars, contacts, briefcases, legal intercepts, share settings, forwarders, distribution lists, filters, auto-responders, users, user passwords, domains, etc. To migrate from one Zimbra instance to another; you run export_zimbra.sh on the server that you are migrating from; the best way to do this is to use “screen” – if you don’t know what it is check out: https://linuxize.com/post/how-to-use-linux-screen/ – I personally love screen because if your terminal gets disconnected whatever you are doing will continue to run.

The README file has pretty comprehensive instructions on how to use.
https://github.com/hodfords/zimbra-migration/blob/main/README.md

Depending on how many accounts you have and how much content you have it may take a day or two to complete the export process. The default location where all of the backup content will reside is:-

/opt/zmbackup/

So make sure that you have enough spare storage space within your partition to store all of the backup data.

Once the export process is complete; you need to use the import_zimbra.sh script which will import all of the content and settings that you have just exported. Again – it is really key that you use “screen” or some kind of method that allows you run this for a few days without breakage to the connection. There are a few scripts you will need for the import script to work such as imapsync https://imapsync.lamiral.info/ which is a really useful program that will copy emails from one server to another. Other linux programs such as rsync, sed, cut, stats, etc. are also needed. Incidentally you do need to make import_zimbra.sh executable – e.g.

chmod 755 import_zimbra.sh

as it is a bash script and you need to make it executable before your system will allow you to execute

The script is really simple to use and all you need to run to start the migration is:-

./import_zimbra.sh 111.222.333.444

where 111.222.333.444 is the IP address of the server you are migrating from; once this command is run you will prompted for the root password of the old server so that all of the content can be copied (using rsync) to the new server. I have checked that the code carefully and it doesn’t store any of the passwords or send any sensitive anywhere – so you don’t need to worry about some spyware trying to capture all of your sensitive information. But if you are really paranoid you can create a directory on the new server called /opt/zmbackup/ and then manually copy all of the content files (using rsync is highly recommended) from the old server also stored in /opt/zmbackup/ and then running the script and then skipping the rsync part by pressing (Ctrl-C together).

The import script will take a while to run; first it will import domain names and user accounts. What I love about this script is that it will migrate all of the user accounts and all of the user passwords. The system will prompt you whether you want to import each part such as contacts, calendars, briefcases, etc. Towards the end it will prompt you whether you want to migrate the emails. The system will prompt you for the Zimbra admin account for the old server and the new server. Again, I have checked the script carefully and the passwords are not stored anywhere except in the memory of the script and once the script finishes all session data will disappear. Incidentally, the migration of the emails are done by imapsync and this part will take a long time to complete; I think for one server of mine it took like 10 days because we had so many accounts.

I had a few accounts with a crazy number of emails like 1 million+ emails and it crashed imapsync and I found that the only way to get around this was to add more RAM to the server; if you are using a virtualised environment then this is probably easier; I increased the RAM from 16 Gb to 32 Gb and imapsync was finally able to copy over all of the 1 million+ emails for this one monster email account.

This migration script is really great as there is now a migration script for migrating to Carbonio which is a new email platform that is set to replace Zimbra. The exact same method can be applied; except there is a script called import_carbonio.sh instead of import_zimbra.sh which you must run on your new Carbonio box.

All in all, I was pleased that somebody finally came up with this script and it has been really for us. In fact, thanks to Hodfords https://www.hodfords.com/ for their contribution with this script; it is completely free to use and is launched as under the GNU license.