- This is certified documentation and is protected for editing by Zimbra Employees & Moderators only.

- This article is a Work in Progress, and may be unfinished or missing sections.

Purpose

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.

Prerequisites

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. For more information check the "Additional Content" section at the bottom of the page.

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 file.sh) 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.

Resolution

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

2. Backup the data from the "client".

2.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")

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

#!/bin/bash
# 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`
do
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*
done

10. Backup Resource/s.

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:

dc=domain,dc=com

As you substitute the above "domain" and "com" with your specific information. The rest is the same as in point 8, as you click on the resource users in order to export them.

11. RSYNC the backed up data to the new server.

rsync -e ssh -axvzKHS /migration/ root@10.0.0.1:/migration/

The 10.0.0.1 is the IP of the "source" server.

On the new server (SOURCE)

1. Restore COS.

To import to the "source" server:

Create new entry in the JXplorer as in the import, but this time specify the "source" server IP.

Click on the "cos"

LDIF > Import File > Select File > Import

Do that with all COS you want to import.

2. Restore Resource/s.

Same as restoring COS, except the difference in the binding base dn, explained above in point 10.

6. Add the migrated users from the "client" to their respective COS on the "source".

#!/bin/bash
# The script first list the exported cos names, then iterate through all members within this cos and finally assigns the
# user to the COS.
for cos in `/bin/ls -1 /migration/cos_users | tr " " "\n"`
do
for i in `cat /migration/cos_users/$cos`
do
zmprov sac $i $cos
done
done

7. Recreate the distribution lists.

for i in `cat dlist.txt`; do zmprov cdl $i ; echo "$i done " ; done

8. Add members to the distribution lists.

#!/bin/bash
# add all memebers to each of these distribution lists
if [ $(whoami) != 'zimbra' ]; then
echo "Must be zimbra to run $0"
exit 1;
fi
for i in `cat /migration/dlist.txt`
do
for j in `grep -v '#' dl/$i.txt |grep '@'`
do
zmprov adlm $i $j
echo " $j has been added to list $i"
done
done

9. Restore the aliases.

#!/bin/bash
if [ $(whoami) != 'zimbra' ]; then
echo "Must be zimbra to run $0"
exit 1;
fi
for i in `cat /migration/accounts.txt`
do
if [ -f "alias/$i.txt" ]; then
for j in `grep '@' /migration/alias/$i.txt`
do
zmprov aaa $i $j
echo "$i has alias $j"
done
fi
done

10. Post steps.

Shut down the "client" server

Fix DNS

Confirm your accounts and domains are present and show active, as zimbra run: zmaccts