Migrate Zimbra From One Server To Another Server | Method-1 | Zimbra

Alert! This article is written for Zimbra OSE users. As of December 2023, Synacor will no longer be providing support for Zimbra OSE. You might want to consider trying out Carbonio Community Edition – Zextras’s free and open-source email and collaboration platform.

For additional guidance, check out our community articles detailing the process of migrating from your current platform to Carbonio CE.

This will be a series of articles. We will write three (3) articles in this series to show you how to migrate your Zimbra server from one server to another. So at the end of this series, you will have a clear idea about the migration process, and you will be able to choose between them.

What To Keep In Mind Before Migration

Migration needs a lot of planning and attention. Therefore, system admins often hesitate to migrate even if it must be done.

Before migration, you should think about three things:

  • Backup
  • Downtime
  • Approach


Migration is a critical process. If it goes wrong, you might lose all of your data; your system may become unstable/unusable.

Please take a backup of your existing data before starting any backup, restore, or maintenance process.

Your backup will help you to decide what type of approach you are going to follow.


Downtime is one of the key factors that you should consider before planning any migration. It will also affect your approach selection.


There are several approaches to migrating Zimbra from one server to another server. Two key factors to consider selecting approaches.

  • Service migration followed by data migration
  • All Out-migration

Service Migration Followed By Data Migration

In this case, you migrate your service from the old server to the new server by changing necessary DNS records. Once you do this, your email service becomes active in your new server without any data. Then you gradually transfer your data from the old server to the new server.

In this case, your downtime is minimal. But the challenge is your user will get their data gradually.

We will learn some migration techniques in this series that follow this approach.

All out migration

In this migration method, you can migrate the data and service within an estimated time frame. So you can understand there is a down time involved in this method. The bigger the data is the higher the downtime will be. After the downtime as soon as your process completes, your service and data will be available to your users.

Can be useful when:

  • You have relatively mid size data on a single server infrastructure
  • You are just migrating the exiting server to another upgraded hardware
  • The zimbra version of old server and new server would be same

Service Migration Followed By Data Migration – (Method-1)

We will describe all steps so that you can easily follow them.

Let’s assume you have a Zimbra server that needs to be migrated to another server hardware. Let me show you an illustrated overview of this method.


Backup/Export User Data without email

Prepare another server hardware. Install your desired OS on the new server. On of our previous articles will help you to choose the best operating system for your server.

Install Zimbra on your new server. Don’t miss the recommendations to prepare the server for the zimbra.

Extract all user information from the old server so we can create them on the new server.

Email migration steps-1

*** You can extract/export this information to your old server or any other storage device. If you are extracting data on the same server, remember that you should have enough free space. To extract this information, use the following commands:

Create a directory and set the necessary permissions

root@mail:~#mkdir -p /opt/backups/zmigrate
root@mail:~#chown zimbra.zimbra /opt/backups/zmigrate
root@mail:~# cd /opt/backups/zmigrate
root@mail:/opt/backups/zmigrate# su zimbra

Export domains, email accounts, and distribution lists

zimbra@mail:/opt/backups/zmigrate$ zmprov gad > domains.txt
zimbra@mail:/opt/backups/zmigrate$ zmprov -l gaa > emails.txt
zimbra@mail:/opt/backups/zmigrate$ zmprov gadl > distributionlist.txt

Export distribution list members’ information

zimbra@zimbra:~$ mkdir /opt/backups/zmigrate/distributionlist_members
zimbra@mail:/opt/backups/zmigrate$ for i in `cat /opt/backups/zmigrate/distributionlist.txt`; do zmprov gdlm $i > /opt/backups/zmigrate/distributionlist_members/$i.txt ;echo "$i"; done

Export email accounts’ passwords

zimbra@mail:/opt/backups/zmigrate$ mkdir userpass
for i in `cat emails.txt`; do zmprov  -l ga $i userPassword | grep userPassword: | awk '{ print $2}' > userpass/$i.shadow; done

Export User Data – All user display name

zimbra@mail:/opt/backups/zmigrate$ mkdir userdata
for i in `cat emails.txt`; do zmprov ga $i  | grep -i Name: > userdata/$i.txt ; done


Transfer Data From Old Server To New Server

Again Create a directory and set the necessary permissions in the new server.

root@mail:~#mkdir -p /opt/backups/zmigrate
root@mail:~#chown zimbra.zimbra /opt/backups/zmigrate
root@mail:~# cd /opt/backups/zmigrate
root@mail:/opt/backups/zmigrate# su zimbra

Now you have all required information except email data in the OLD server. Transfer them to the new server. You can use rsync or any other tool to transfer these data. For example:

[In OLD Server]
rsync -avp -e /opt/backups/zmigrate/* root@new_server_ip:/opt/backups/zmigrate/* 


Import User Data To the New Server

Import all transferred data into the new server using the following processes.

Email migration steps-3

Follow the below-mentioned process in the NEW server.

Restore all domains

zimbra@mail:/opt/backups/zmigrate$for i in `cat /opt/backups/zmigrate/domains.txt `; do  zmprov cd $i zimbraAuthMech zimbra ;echo $i ;done

Create/Restore all email accounts with old passwords and user data in the NEW server

[Create below mentioned script and execute it]
#Script for creating the email accounts createacct.sh
for i in `cat $USERS`
givenName=$(grep givenName: $USERDATA/$i.txt | cut -d ":" -f2)
displayName=$(grep displayName: $USERDATA/$i.txt | cut -d ":" -f2)
shadowpass=$(cat $USERPASS/$i.shadow)
zmprov ca $i CHANGEme cn "$givenName" displayName "$displayName" givenName "$givenName"
zmprov ma $i userPassword "$shadowpass"

This script will create all email addresses with their existing display name and password in the new server.

Recreate distribution list

zimbra@mail:/opt/backups/zmigrate$ for i in `cat distributionlist.txt`; do zmprov cdl $i ; echo "$i -- done " ; done

Restore distribution list members as per previous arrangements

[Create below mentioned script and execute it]
# add all members to each of these distribution lists
for i in `cat distributionlist.txt`
          for j in `grep -v '#' distributionlist_members/$i.txt |grep '@'`
          zmprov adlm $i $j
          echo " $j member has been added to list $i"

This script will create all distribution lists with their existing members.


Service Migration From Old Server To New Server

So far, we have exported all user information from the OLD server to the NEW server. So now we can change necessary DNS records so that the NEW server can be the active email server.

Change DNS records to make the NEW server an active server.

As soon as DNS records propagate, all users can log in to their email account using their existing credentials. But in their account, there will be no previous data. Now we will work to transfer email data.


Email Data Migration

Export all email data from OLD server

zimbra@mail:/opt/backups/zmigrate$ mkdir MBOX
zimbra@mail:/opt/backups/zmigrate/MBOX$for email in `cat /opt/backups/zmigrate/emails.txt`; do zmmailbox -z -m $email getRestURL '/?fmt=zip' > $email.zip ; echo $email ; done


Transfer Email Data to New Server
Transfer these data from the OLD server to the NEW server using rsync or any other tool.


Import All Email Data To The NEW Server

zimbra@mail:/opt/backups/zmigrate/MBOX$for i in `cat /opt/backups/zmigrate/emails.txt`; do zmmailbox -z -m $i -t 0 postRestURL "/?fmt=zip&resolve=skip" /opt/backups/zmigrate/MBOX/$i.zip ; echo "$i -- finished "; done

After finishing this task, all users will get their previous email data in their email accounts.

As you can see from this method, it is platform-independent. Also, it does not transfer OLD server settings to the new server. You have to set all settings as per previous arrangements manually in the new server.

This is a customized manual method of server migration. But if you think your server infrastructure is a bit complex to manage and need enterprise expertise to help you migrate, you can check Zextras Suite.

So this is it. In the next article, we will discuss another method of migration.

Till then, stay safe.
Have a good day.

Download Zextras Suite for Zimbra OSE



when we execute command export all email data on OLD SERVER, is the original data still exist? honestly it's just a worry for data loss. thx a lot

Md. Shariful Islam

Hi Chameleon, Yes, the original data still exists on the server. This step only extracts/downloads the data without removing the original one. To be more more clear, it acts just like the export/import feature as the GUI. And if you have tried/tested the export/import feature on GUI, you know they just download the data without removing the original one. Lastly, you can always test this step on a test account to be sure about your worries 😊 Thanks and regards, Sharif


Great...!!! This guide is very very use full for me. Thx a lot


Hello. I will try to migrate from zimbra 8.8.8 to carbonio 22.12.0, everything works fine, until step-7. In the step-7 I try this: $zmmailbox -z -m hmolina@midominio.com -t 0 postRestURL "/?fmt=zip&resolve=skip" hmolina@midominio.com.zip I obtain the error: ERROR: zclient.IO_ERROR (Connection refused) (cause: java.net.ConnectException Connection refused) To try to fix, I ran this: $zmlocalconfig -e zimbra_zmprov_default_to_ldap=true But the error persist. I appreciate any orientation. Regards

Md. Shariful Islam

Hi Jaimeco, Could you please try this 4 steps first: 1. zmprov md sampleserver.xyz zimbraPublicServicePort 443 2. zmprov md sampleserver.xyz zimbraPublicServiceProtocol https 3. zmprov mcf zimbraPublicServiceHostname mail.sampleserver.xyz 4. zmmailboxdctl restart Then try zmmailbox -z -m hmolina@midominio.com -t 0 postRestURL "/?fmt=zip&resolve=skip" hmolina@midominio.com.zip Thanks,


Hello. Thank you Md. Shariful. I ran this: zextras@mail:/opt/backups/zmigrate/MBOX$ ls hmolina@midominio.com.zip zextras@mail:/opt/backups/zmigrate/MBOX$ zmmailbox -v -z -m hmolina@midominio.com -t 0 postRestURL "/?fmt=zip&resolve=skip" hmolina@midominio.com.zip But it only returns the prompt. The mailbox user is still empty. If there are some suggestions I will appreciate them.

Post your comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Cloud computing & data sovereignty for dummies: What's the cloud? | Blog
An Overview of the Webmail Interface in Carbonio Community Edition | Carbonio CE