How to merge two independent ZCS servers into one

Revision as of 00:55, 24 December 2016 by Teodor Vizirov (talk | contribs) (How to merge two independent ZCS servers into ONE)

How to merge two independent ZCS servers into ONE

   KB 23120        Last updated on 2016-12-24  

(0 votes)


This article covers the following:

Case scenario: There are two separate zimbra server, not connected in any way. The aim is to move the data from one of the servers to the other.

The steps below can be used to move a server to another new server too, or to another ZCS server in multi server environment.


Lets call the server that the data will be moved to the "SOURCE", and the server that will move its data to the "source" the "CLIENT". The "source" and the "client" must have the same hostnames prior this operation. The OS versions of the "source" and the "client" can be different. Eg. migrate from centos to ubuntu is ok. The Zimbra versions must be the same, because we will be doing ldap export and import, which doesn't work if the ldap schema is different.

During the steps below, there are couple of scripts to be run. Make sure you make them executable (chmod +x before that. If you are using vim to paste the text, use :set paste before pasting, otherwise when you paste the text the formatting will be gone.


Overview of the steps:

On both servers create base directories for the migration:

# mkdir /migration
# chown zimbra.zimbra /migration

On the old server (CLIENT):

1. Become zimbra

# su - zimbra

3. Backup the data from the "client".

3.1. backup the domains:

cd /migration
zmprov gad > domains.txt

(open the domains.txt and remove all domains/subdomains that already exists on the "source")

3.2 backup all admins

cd /migration
zmprov gaaa > admins.txt

3.3 backup all accounts

cd /migration
zmprov -l gaa > accounts.txt

(open the file accounts.txt and remove the accounts starting with: spam,ham,virus,galsync)

3.4. add the calendar resources to the accounts file

zmprov gacr >> accounts.txt

3.5 backup all distribution lists

cd /migration
zmprov gadl > dlist.txt

3.6 backup all members of the distribution lists

cd /migration
mkdir dl
for i in `cat /migration/dlist.txt`; do zmprov gdlm $i > /migration/dl/$i.txt ;echo "$i"; done

4. backup all account passwords

cd /migration
mkdir userpass
for i in `cat accounts.txt`; do zmprov  -l ga $i userPassword | grep userPassword: | awk '{ print $2}' > userpass/$i.shadow; done

5. backup all user,display and given names

cd /migration
mkdir userdata
for i in `cat accounts.txt`; do zmprov ga $i  | grep -i Name: > userdata/$i.txt ; done

6. backup all accounts data

cd /migration
mkdir accounts
for account in `cat /migration/accounts.txt`; do /opt/zimbra/bin/zmmailbox -z -m $account -t 0 getRestURL "//?fmt=tgz" > accounts/$account.tgz ;  echo $account done; done

7. backup aliases

cd /migration
mkdir alias
for i in `cat accounts.txt`; do zmprov ga  $i | grep zimbraMailAlias |awk '{print $2}' > alias/$i.txt ;echo $i ;done

Remove the ones that are empty files:

find /migration/alias/* -size 0 | xargs rm -f

8. backup COS (if different from the "source" server) If you have only the default COS on the "client", but its with different settings from the COS on the "source" server, you have to rename it and then import it under different name.

JXPlorer (

download JXPlorer from (it is free software) Create new entry as follows: Host: "client" server IP Port 389 ; Protocol v3 Base DN: cn=zimbra Authentication: Level: User + Password User DN: cn=config Password is the output from: zmlocalconfig -s ldap_root_password

Click OK.

From the left Tree View, expand "cos" Select the COS that you want to export&move to the "source" server From the File menu line above, click on LDIF > Export Subtree > Save on the local disk.

Do that with all COS you want to move.

(leave the JXplorer open for the import)

9. Create files for each COS, and their respective user members.

mkdir /migration/cos_users


# The result is a file/s for each COS, and the users within this specific COS
# Note: If there are no custom created COS, there will be no users listed in the default and default_external files. That 
# means all users are in the "default" COS.
# Since the default and the default_external files will contain no users, their respective files are deleted at 
# the end. Zimbra only detect users that are not in the default COS. Thus, every non detected user is in the default COS. 
source ~/bin/zmshutil; zmsetvars
for i in `zmprov gac`
       id=`zmprov gc $i | grep -e "\bzimbraId\b"|cut -d " " -f 2`
       ldapsearch -x -H $ldap_master_url -D $zimbra_ldap_userdn -w $zimbra_ldap_password| grep -e $id -e "dn: uid=" -e mail:|grep -v Email| grep -e zimbraCOSId -B1 -A1|grep mail|awk '{print $2}' > /migration/cos_users/$i
/bin/rm -rf /migration/cos_users/default*

10. backup Resource

The resource backup is the same as the COS explained in point 8 above. The one difference is that you need to specify different "Base DN:" when you login. The Resource is type of a user, and to see the users, we need to use the following bind dn:


Az you substitute the above "domain" and "com" with your specific information. The rest is the same as in point 8.


RSYNC to the new server.

rsync -e ssh -axvzKHS  /migration/ root@

The is the IP of the "source" server.

On the new server

Additional Content

Verified Against: Zimbra Collaboration 8.7, 8.6, 8.0 Date Created: 28/09/2016
Article ID: Date Modified: 2016-12-24

Try Zimbra

Try Zimbra Collaboration with a 60-day free trial.
Get it now »

Want to get involved?

You can contribute in the Community, Wiki, Code, or development of Zimlets.
Find out more. »

Looking for a Video?

Visit our YouTube channel to get the latest webinars, technology news, product overviews, and so much more.
Go to the YouTube channel »

Wiki/KB reviewed by SME1 SME2 COPY EDITOR Last edit by Teodor Vizirov
Jump to: navigation, search