For additional guidance, check out our community articles detailing the process of migrating from your current platform to Carbonio CE.
For enterprise-level requirements and advanced features, consider checking out Zextras Carbonio – the all-in-one private digital workplace designed for digital sovereignty trusted by the public sector, telcos, and regulated industries.
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
Backup
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
Downtime is one of the key factors that you should consider before planning any migration. It will also affect your approach selection.
Approach
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.
Step-1
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.
*** 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
zimbra@mail:/opt/backups/zmigrate$
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
zimbra@mail:/opt/backups/zmigrate$
for i in `cat emails.txt`; do zmprov ga $i | grep -i Name: > userdata/$i.txt ; done
Step-2
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/*
Step-3
Import User Data To the New Server
Import all transferred data into the new server using the following processes.
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]
#!/bin/bash
#Script for creating the email accounts createacct.sh
USERPASS="/opt/backups/zmigrate/userpass"
USERDATA="/opt/backups/zmigrate/userdata"
USERS="/opt/backups/zmigrate/emails.txt"
for i in `cat $USERS`
do
givenName=$(grep givenName: $USERDATA/$i.txt | cut -d ":" -f2)
displayName=$(grep displayName: $USERDATA/$i.txt | cut -d ":" -f2)
shadowpass=$(cat $USERPASS/$i.shadow)
tmpPass="CHANGEme"
zmprov ca $i CHANGEme cn "$givenName" displayName "$displayName" givenName "$givenName"
zmprov ma $i userPassword "$shadowpass"
done
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]
#!/bin/bash
# add all members to each of these distribution lists
for i in `cat distributionlist.txt`
do
for j in `grep -v '#' distributionlist_members/$i.txt |grep '@'`
do
zmprov adlm $i $j
echo " $j member has been added to list $i"
done
done
This script will create all distribution lists with their existing members.
Step-4
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.
Step-5
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
Step-6
Transfer Email Data to New Server
Transfer these data from the OLD server to the NEW server using rsync or any other tool.
Step-7
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.
Comments
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
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
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.
halu... ive got this message below while importing the email account data : ERROR: zclient.IO_ERROR (Broken pipe (Write failed)) (cause: java.net.SocketException Broken pipe (Write failed)) could you please help me to analyze this issue, please. thank you.
In Step-5 Email Data Migration Export all email data from OLD server I am getting below error: /opt/zimbra/bin/zmmailbox -z -m admin@domain.com-t 0 getRestURL “//?fmt=tgz” > /tmp/account.tgz ERROR: zclient.IO_ERROR (Unable to get resource from 'http://mail.domain.com/home/admin@domain.com/%E2%80%9C?fmt=tgz”' : Connect timed out) (cause: java.net.SocketTimeoutException Connect timed out) I have searched out but could not find any solution,