Migration: Step by Step Zimbra to Carbonio ( imapsync )

 Step:1 Create a directory under both servers:

mkdir -p /backups/zmigrate

 Change the ownership:


chown -R zimbra.zimbra /backups/zmigrate

 

Step: 2 From Old Server Execute the below commands using Zimbra user: to take a backup of all required data:

 cd /backups/zmigrate

 

i) Find all domain names:

zmprov gad > domains.txt

 

ii) Find all admin accounts:

zmprov gaaa > admins.txt

 

iii) Find all email accounts:

zmprov -l gaa > emails.txt

 

iv) Get all distribution lists:

zmprov gadl > /backups/zmigrate/distributionlist.txt

 

v) Get all members in the distribution lists:

mkdir /backups/zmigrate/distributionlist_members

 

for i in `cat /backups/zmigrate/distributionlist.txt`; do zmprov gdlm $i > /backups/zmigrate/distributionlist_members/$i.txt ;echo "$i"; done

 

vi) Find all email accounts’ passwords:

mkdir userpass

 

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

 

vii) Backup all user names , Display names and Given Names:

mkdir userdata

 

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

 

 

Step: 3 Pull all backup data to the new server from old:

 

Rsync folder to new server:

rsync -avp -e 'ssh -p 22' root@old-server-ip:/backups/zmigrate /backups/

 

Step: 4 Restore on the new server:

Login to the new server and execute the below commands using zimbra user.

 

i) Restore all domains:

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

 

ii) Create email accounts and set the old password:

#!/bin/bash

#Script  for creating the email accounts createacct.sh

USERPASS="/backups/zmigrate/userpass"

USERDDATA="/backups/zmigrate/userdata"

USERS="/backups/zmigrate/emails.txt"

for i in `cat $USERS`

do

givenName=$(grep givenName: $USERDDATA/$i.txt | cut -d ":" -f2)

displayName=$(grep displayName: $USERDDATA/$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

 

iii) Recreate the distribution lists:

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

 

iv) Restore the distribution lists:

#!/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

 

 Step:5 Import Date from old to new server:

 

i)             IMAP Sync in new server (Carbonio)

root@mail:/opt/zextras/backup#

docker pull gilleslamiral/imapsync

ii)            Run below command for IMAP migration:

for i in $(su - zextras -c "carbonio prov -l gaa sampleserver.xyz");do docker run --rm gilleslamiral/imapsync imapsync --host1 IP_ZIMBRA_SERVER --ssl1 --user1 $i --authuser1 admin --password1 123456 --host2 IP_CARBONIO_SERVER --ssl2 --user2 $i --authuser2 zextras --password2 123456 ; done

Comments

Popular posts from this blog

Squid Configuration

Squint Configure

Postfix SASL authentication with SMTP port 465:

How to Change the Logo from Zimbra Admin Console