Zimbra Server Migration and Zimbra Account Transfer – The Perfect Method

Get a Zimbra server Support Service Now 75USD

1. Introduction

Zimbra project doesn’t have a cross migration or proper account transfer documentation. All they tell is to do copy the folder /opt/zimbra to your new servers. But if any of those files infected with a rootkit or other malicious scripts , then your new server also will be compromised. So never sync or copy the entire directory of your zimbra installation. Zimbra also tell you to upgrade your production server to the latest version before migration. But improper upgrade may result in entire data lose. With this procedure you can do:

  • Migrate zimbra from one Operating System To another.
  • Migrate zimbra account between any hardware and Operating systems configurations.
  • No interruption on production server like software upgrade or service disable.
  • Migrate zimbra from old version to a new version server
  • Zimbra cross migrations without copying entire directories.

2. Requirement

You need an old server with zmibra account and a new fresh server with the Os you wish. Dont’ create or make any custom configuration or setting in you new server. Please make sure to set your new servers hostname same as the old one.

  • Old server
    • Need ssh root login
    • Need zimbra admin logins
    • Enough HDD space to store backups
  • New server
    • Must be installed with latest stable zimbra
    • Need ssh root logins
    • Need zimbra admin logins
    • Enough HDD space to store backups

3. Presetup

You need to setup an ssh key from the new server’s root account to the old server’s root account.
Reduce the TTL of MX records of your domain to 500 seconds . So that you can easily switch the domain’s IP after migration. Please remember to schedule the migration task on non peek hours.

Create a directory in both new and old server into which we store all required files and data for doing the migration

[root@zimbra ~]# mkdir /backups/zmigrate
[root@zimbra ~]# chown zimbra.zimbra /backups/zmigrate
[root@zimbra ~]# su - zimbra

All operation in your Zimbra server must be performed as Zimbra user itself, otherwise you will get permission and ownership issues in your zimbra server

4. Backup all data from Old server

We are going to copy all data from old server without interrupting the services.

4.1 Find all domains

You need to find all the domains from your old server. We will store the domain list in a file called domains.txt. You need to back all the domains list as follows,

zimbra@zimbra:~$ cd /backups/zmigrate
zimbra@zimbra:/backups/zmigrate$ zmprov gad > domains.txt
zimbra@zimbra:/backups/zmigrate$ cat domains.txt
fun.com
myserver.com
justfortest.com
checkit.com
dieanotherday.com
gnutest.com
foo.com
zimbra.foo.com
zimbra@zimbra:/backups/zmigrate$

Now remove all domains and subdomains related with the main hostname of your server foo.com , from this list (domains.txt) because it was already created in your new server. So there is no need to create a new domain with the same name.

4.2 Find all admin accounts

Most of these servers will have only one admin. But some servers have multiple admins. So it will be good to find all admin accounts. We will store the admins list in admins.txt

zimbra@zimbra:/backups/zmigrate$ zmprov gaaa > admins.txt
zimbra@zimbra:/backups/zmigrate$ cat admins.txt
admin@foo.com
zimbra@zimbra:/backups/zmigrate

4.3 Find all email accounts

Next step is to find all the email accounts hosted in your old server. Get a list of your email accounts and save in the file emails.txt . So from this file we can see how many accounts that need to migrate.

zimbra@zimbra:/backups/zmigrate$ zmprov -l gaa >emails.txt
zimbra@zimbra:/backups/zmigrate$ cat emails.txt
gm@fun.com
forest@fun.com
galsync@fun.com
fax@myserver.com
paul@myserver.com
angela@myserver.com
brooke@myserver.com
hnmobile1@myserver.com
maria@justfortest.com
samantha@justfortest.com
backupmail@justfortest.com
admin@checkit.com
sandra@checkit.com
zimbra@zimbra:/backups/zmigrate$

Please remove all the email accounts from the file /backups/zmigrate/emails.txt with a starting words like spam, virus, ham, galsync . There is no need to restore these accounts. Even if you still need to restore , you can do it. I don’t like spam and virus emails.

4.4 Get all distribution lists

You need to get all the distributions list and store it in a file called distributinlist.txt.

 
zimbra@zimbra:~$ zmprov gadl > /backups/zmigrate/distributinlist.txt
zimbra@zimbra:~$ cat /backups/zmigrate/distributinlist.txt
budgetrtodomainusers@fun.com
healthnowdomainusers@myserver.com
checkit.comdomainusers@checkit.com
northpointessdomainusers@dieanotherday.com
parkatnorthhillsdomainusers@gnutest.com
zimbra@zimbra:~$

4.5 Get all members in distribution lists

In this step we are going to collect all members in each of these distributions. We will create a folder called distributinlist_members and create a file under this folder named distributinlist.txt , then store all the distributions members.

zimbra@zimbra:~$ mkdir /backups/zmigrate/distributinlist_members
zimbra@zimbra:~$ for i in `cat /backups/zmigrate/distributinlist.txt`; do zmprov gdlm $i > /backups/zmigrate/distributinlist_members/$i.txt ;echo "$i"; done
budgetrtodomainusers@fun.com
healthnowdomainusers@myserver.com
checkit.comdomainusers@checkit.com

4.6 Find all email account’s passwords

Now need to find the encrypted password of all of your old email accounts and store it under a folder named userpass/ as follows:

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

4.7 Backup all user names , Display names and Given Names

Zimbra will accept a Names and Disaplay names in email accounts during account creation. So we need to restore those data too. We will create a directory called userdata/ which contains these details of each of those email accounts

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

4.8 Now backup all email account

This will take some time to take backup of all email accounts. So you can run this command behind “screen”. A tgz file will be created with each emails name. We will use this files to transfer email accounts.

 
zimbra@zimbra:/backups/zmigrate$ for email in `cat /backups/zmigrate/emails.txt`; do  zmmailbox -z -m $email getRestURL '/?fmt=tgz' > $email.tgz ;  echo $email ; done
gm@fun.com
forest@fun.com
galsync@fun.com
fax@myserver.com
fax2@myserver.com
paul@myserver.com

This tgz files contains

  • Mail
  • Contacts
  • Calendars
  • Briefcase
  • Tasks
  • Searches
  • Tags
  • Folders

All subfolders are included, except Junk and Trash. There is no way to include these in the big dump, but they can be exported separately:

4.9 Now backup alias

Some times your server may have email aliases for certain accounts. So you need to copy those aliases too. We will create a sub folder called alias/ for storing the backup of Alias.

 
zimbra@zimbra:/backups/zmigrate$ mkdir -p alias/
zimbra@zimbra:/backups/zmigrate$ for i in `cat emails.txt`; do zmprov ga  $i | grep zimbraMailAlias |awk '{print $2}' > alias/$i.txt ;echo $i ;done
gm@fun.com
forest@fun.com

Some of your email accounts don’t have alias. So the above created files may be an empty file. Remove those empty files as follows,’\

zimbra@zimbra:/backups/zmigrate$ find alias/ -type f -empty | xargs -n1 rm -v 

4.10 Now Backup all email signatures

Please use the following script to backup all signatures of email accounts. Special thanks for Antonio Díaz Meneses for giving the inputs.

#!/bin/bash

mkdir signature
for i in `cat emails.txt`; do
	zmprov ga $i zimbraPrefMailSignatureHTML > /tmp/signature;
	sed -i -e "1d" /tmp/signature ;
	sed 's/zimbraPrefMailSignatureHTML: //g' /tmp/signature > signatures/$i.signature ;
	rm -rf /tmp/signature;
	`zmprov ga $i zimbraSignatureName > /tmp/name` ;
	sed -i -e "1d" /tmp/name ;
	sed 's/zimbraSignatureName: //g' /tmp/name > signatures/$i.name ;
	rm -rf /tmp/name ;
done

4.11 Backup all email account filters

The email backup doesn’t have the email filters. So it need to be backed up manually. To download all email accounts filters. Please use the following scripts

#!/bin/bash
# Backup filters of all email accounts
mkdir filter/
for i in `cat emails.txt`; do
    zmprov ga $i zimbraMailSieveScript > /tmp/filter
    sed -i -e "1d" /tmp/filter
    sed 's/zimbraMailSieveScript: //g' /tmp/filter  > filter/$i.filter
    rm -f /tmp/filter
    echo "Filter  downloaded for .... $i"
done 

4.12 Rsync folder to new server

Now we have all the required data to do the migration process. As a summery :

  • /backups/zmigrate – Have all the backups stored
  • /backups/zmigrate/domains.txt – Contains the domains names
  • /backups/zmigrate/emails.txt – Contains the list of email accounts
  • /backups/zmigrate/distributinlist.txt – Contains the distribution lists
  • /backups/zmigrate/distributinlist_members – Contains the members in each of your distributions
  • /backups/zmigrate/userpass – Contains the encrypted password of your email accounts
  • /backups/zmigrate/userdata – containts the email accounts user informations
  • /backups/zmigrate/alias – Contains all the aliases of your email accounts

Also the parent folder /backups/zmigrate contains a lot of zip file which are the data inside emails.

Now rsync the files as follows,

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

5. Restore in new server

So after finishing the rsync process , we need to restore this in your new server as follows:

All this operations must be carried out as zimbra sudo user itself. Don’t use root account to store the backups

[root@zimbra ~]# su - zimbra
[zimbra@zimbra]$

5.1 Restore all domains

Now create all the domains that we have from the file /backups/zmigrate/domains.txt

[zimbra@zimbra zmigrate]$ for i in `cat /backups/zmigrate/domains.txt `; do  zmprov cd $i zimbraAuthMech zimbra ;echo $i ;done
2c86f244-de9d-4b7c-8e22-2246a8256219
myserver.com
dbf75058-d85e-4d60-8b69-1f148a456eb6
justfortest.com
ee90ffa2-505d-449f-82fd-129acb21cb5e
checkit.com
8b6bf287-f61e-4930-ada0-96b817292556
dieanotherday.com
17d3c73c-14f7-43aa-9fd2-c9be9e29c9e5

You can also verify the domains created from the zimbra admin panel too

5.2 Create email accounts and set the old password

We need to create the email accounts for storing the mails. We also need to set the old passwords too. We already collected the account info and passwords.

To Create email accounts and restore passwords . Please use the following script to create it

#!/bin/bash
#Scrit  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

5.3 Restore email accounts

Now we are going to restore the emails from the Zip file. This process may take some hours. So it will be good to run behind “screen” command.

[zimbra@zimbra zmigrate]$ for i in `cat /backups/zmigrate/emails.txt`; do zmmailbox -z -m $i postRestURL "/?fmt=tgz&resolve=skip" /backups/zmigrate/$i.tgz ;  echo "$i -- finished "; done
gm@fun.com -- finished 
forest@fun.com -- finished 

5.4 Now recreate the distribution lists

It is time to recreate all the distribution lists as follows.

[zimbra@zimbra zmigrate]$ for i in `cat distributinlist.txt`; do zmprov cdl $i ; echo "$i -- done " ; done
2a852fd8-6e66-426e-a76d-15192536042a
budgetrtodomainusers@fun.com -- done 
a0f6ddb3-8525-4194-9397-6cf0a920dda6

5.5 Restore the distribution lists

After creating the distribution lists we need to add all the members inside the distribution lists. We have the distribution lists in the folder distributinlist_members/ and the list is in distributionlist.txt file. Please use the following small script to restore the distribution lists.

[zimbra@zimbra zmigrate]$ cat restoredist.sh 
#!/bin/bash
# add all memebers to each of these distribution lists
for i in `cat distributinlist.txt`
do
	for j in `grep -v '#' distributinlist_members/$i.txt |grep '@'` 
	do
	zmprov adlm $i $j
	echo " $j member has been added to list $i"
	done

done

5.6 Restore Alias accounts

Please use the following script to restore alias. This will add all the aliases in your email accounts.

#!/bin/bash
for i in `cat /backups/zmigrate/emails.txt`
do
	if [ -f "alias/$i.txt" ]; then
	for j in `grep '@' /backups/zmigrate/alias/$i.txt`
	do
	zmprov aaa $i $j
	echo "$i HAS ALIAS $j --- Restored"
	done
	fi
done

5.7 Restore Email Signatures

No please use the following script to restore email signatures

#!/bin/bash
for i in `cat emails.txt`; do
	zmprov ma $i zimbraSignatureName "`cat signatures/$i.name`";
	zmprov ma $i zimbraPrefMailSignatureHTML "`cat signatures/$i.signature`";
	zmprov ga $i zimbraSignatureId > /tmp/firmaid; sed -i -e "1d" /tmp/firmaid;
	firmaid=`sed 's/zimbraSignatureId: //g' /tmp/firmaid`;
	zmprov ma $i zimbraPrefDefaultSignatureId "$firmaid";
	zmprov ma $i zimbraPrefForwardReplySignatureId "$firmaid";
	rm -rf /tmp/firmaid;
	echo $i "done!";
done

5.8 Restore Email Filters

You may use the following scripts to restore all your email accounts filters


#!/bin/bash
for i in `cat emails.txt`; do
    zmprov ma  $i zimbraMailSieveScript "`cat filter/$i.filter`";
    echo "Filter Restore for account ... $i"; 
  
done

6. Conclusion

So now we migrated all our email accounts. It is time for DNS change. You need to shut down the old zimbra services and change the DNS. After that send some test emails and make sure everything is working fine. Next step is to secure your zimbra server. You need to install ssl certificates and firewall in your new zimbra server. Now you have a new server with new packages and files with the same old email accounts and its data.

7. References

https://wiki.zimbra.com/wiki/Zmprov_Examples
https://wiki.zimbra.com/wiki/Zmprov
https://wiki.zimbra.com/wiki/Backing_up_and_restoring_Zimbra_%28Open_Source_Version%29
'https://xmission.com/blog/2015/04/30/zimbra-server-admin-tip-mailbox-password-migration-and-server-settings-comparison'
http://stdout.no/zimbra-open-source-backup-strategy-and-scripts/

Zimbra Server Migration

61 Replies to “Zimbra Server Migration and Zimbra Account Transfer – The Perfect Method”

  1. Hello I have an error when running the command:
    for email in `cat /backups/zmigrate/emails.txt`; do for i in `cat ../emails.txt `; do zmmailbox -z -m $i getRestURL ‘/?fmt=tgz’ > $i.tgz ; echo $email ; done

    copy and paste the same as have your but is dead.

    Greetings from Uruguay

      1. Hi,

        I have an error when running the command:
        for email in `cat /backups/zmigrate/emails.txt`; do zmmailbox -z -m $i getRestURL ‘/?fmt=tgz’ > $i.tgz ; echo $email ; done

        Getting below errors
        ERROR: account.NO_SUCH_ACCOUNT (no such account: getRestURL)
        admin@domainname.in
        ^Ca.sharma@mahagenco.in
        ERROR: account.NO_SUCH_ACCOUNT (no such account: getRestURL)
        abt@domainname.in
        ERROR: account.NO_SUCH_ACCOUNT (no such account: getRestURL)
        acctsparastps@domainname.in

  2. Thanks for the how to you save my life:
    In my zimbra the script to list user to distributing list no echo any result, i research about this and modify your script and voila!

    for i in `cat /backups/zmigrate/distributinlist.txt`; do zmprov gdl $i | grep zimbraMailForwardingAddress: | awk {‘print $2’} > /backups/zmigrate/distributinlist_members/$i.txt ;echo “$i”; done

    thanks

  3. Hi you can add script for filter migration. Here is my example for filter export:

    cat /backups/zmigrate/filters-export.sh
    #!/bin/bash
    set -x
    clear
    echo “Retrieve zimbra user name…”
    USERS=`cat /backups/zmigrate/emails.txt`;
    for ACCOUNT in $USERS; do
    NAME=`echo $ACCOUNT`;
    filter=`su – zimbra -c “zmprov ga $NAME zimbraMailSieveScript” > /tmp/$NAME`
    sed -i -e “1d” /tmp/$NAME
    sed ‘s/zimbraMailSieveScript: //g’ /tmp/$NAME > /backups/zmigrate/filters/$NAME;
    rm /tmp/$NAME
    echo “Export filter for $NAME…”
    done
    echo “All filter has been export successfully”

    And script for import filters:

    #!/bin/bash
    set -x
    for file in /backups/zmigrate/filters/*
    do
    StrFilter=`cat “$file”`
    Acc=$file
    su – zimbra -c “zmprov ma $(echo $file | grep -E -o “\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}\b”) zimbraMailSieveScript ‘$StrFilter'”
    echo “Process filter $Acc”
    done
    echo “All filter has been import successfully”

  4. my developer says me that this is the solution..
    for email in `cat /backups/zmigrate/emails.txt`; do zmmailbox -z -m $email getRestURL ‘/?fmt=tgz’ > $email.tgz ; echo $email ; done

  5. Hi Sherin,

    Add these scripts to manual. It will be great.
    You can fix 4.8

    from:
    for email in `cat /backups/zmigrate/emails.txt`; do zmmailbox -z -m $i getRestURL ‘/?fmt=tgz’ > $i.tgz ; echo $email ; done

    to:
    for email in `cat /backups/zmigrate/emails.txt`; do zmmailbox -z -m $email getRestURL ‘/?fmt=tgz’ > $email.tgz ; echo $email ; done

    variable $i is not defined and must be replaced with $email

  6. when running :-

    4.8 Now backup all email account :-

    for email in `cat /backups/zmigrate/emails.txt`; do zmmailbox -z -m $i getRestURL ‘/?fmt=tgz’ > $i.tgz ; echo $email ; done

    I was getting the following error :-

    ERROR: account.NO_SUCH_ACCOUNT (no such account: getRestURL)

    I modified as follows and it seems to be working :-

    for email in `cat /backups/zmigrate/emails.txt`; do zmmailbox -z -m $email getRestURL ‘/?fmt=tgz’ > $email.tgz ; echo $email ; done

  7. Hi, you’ve made a great tutorial.

    I have some observations:
    – Step 4.8: the variable $i must be $email inside the loop.
    – Step 5.2: All e-mail accounts are active after restoring, even the closed accounts in the old server.
    – Step 5.3: There are two consecutive semicolons that broke the script execution here.
    – I would like to know whether there is a way to migrate COS before restoring e-mails and if you had some kind of tip to deal with special characters, because I have some problem with it after migration (I’m Brazilian and some account display names in Portuguese has special characters).

    Thank you for this tutorial.

  8. In Step 4.8, you’re mixing the variables $email and $i.

    Change:
    for email in `cat /backups/zmigrate/emails.txt`; do zmmailbox -z -m $i getRestURL ‘/?fmt=tgz’ > $i.tgz ; echo $email ; done

    To:
    for i in `cat /backups/zmigrate/emails.txt`; do zmmailbox -z -m $i getRestURL ‘/?fmt=tgz’ > $i.tgz ; echo $i ; done

  9. Hi !
    Nice Work.
    But i think there i a bug in 4.6
    for email in `cat /backups/zmigrate/emails.txt`; do zmmailbox -z -m $i getRestURL ‘/?fmt=tgz’ > $i.tgz ; echo $email ; done

    I think it should be
    for email in `cat /backups/zmigrate/emails.txt`; do zmmailbox -z -m $email getRestURL ‘/?fmt=tgz’ > $email.tgz ; echo $email ; done

  10. Hi, excellent guide. I have already tried in a dev server to see everything works. I’m planning to migrate to a multiserver, from 8.6 to 8.7. I’m going to proceed and backup the mails, and then restore them on the mailstore server of the multi. At the moment, I have already migrated domains, emails, lists and aliases without any problems. Have you tried this process on a multiserver enviroment?

  11. Hello friend. I have 2 corrections for your tutorial:

    for i in `cat /backups/zmigrate/emails.txt`; do zmmailbox -z -m $i getRestURL ‘/?fmt=tgz’ > $i.tgz ; echo $i ; done

    for i in `cat /backups/zmigrate/emails.txt`; do zmmailbox -z -m $i postRestURL “/?fmt=tgz&resolve=skip” /backups/zmigrate/$i.tgz ; echo “$i — finished “; done

    ****** PLEASE, send me your paypal ID, you’ve saved my week. I spent 38 hours doing on-the-fly migration, because your tutorial saved me… send to ti@tempofilmes.com.br Kind Regards.

  12. In case of annoying customers:

    here how to backup / recover the user’s signatures:

    Backup:

    for i in `cat emails.txt`; do
    zmprov ga $i zimbraPrefMailSignatureHTML > /tmp/signature;
    sed -i -e “1d” /tmp/signature ;
    sed ‘s/zimbraPrefMailSignatureHTML: //g’ /tmp/signature > signatures/$i.signature ;
    rm -rf /tmp/signature;
    `zmprov ga $i zimbraSignatureName > /tmp/name` ;
    sed -i -e “1d” /tmp/name ;
    sed ‘s/zimbraSignatureName: //g’ /tmp/name > signatures/$i.name ;
    rm -rf /tmp/name ;
    done

    Recover:

    for i in `cat emails.txt`; do
    zmprov ma $i zimbraSignatureName “`cat signatures/$i.name`”;
    zmprov ma $i zimbraPrefMailSignatureHTML “`cat signatures/$i.signature`”;
    zmprov ga $i zimbraSignatureId > /tmp/firmaid; sed -i -e “1d” /tmp/firmaid;
    firmaid=`sed ‘s/zimbraSignatureId: //g’ /tmp/firmaid`;
    zmprov ma $i zimbraPrefDefaultSignatureId “$firmaid”;
    zmprov ma $i zimbraPrefForwardReplySignatureId “$firmaid”;
    rm -rf /tmp/firmaid;
    echo $i ‘done!’;
    done

  13. Hello,
    I have tried to migrate server with this manual. Works great until step 4.8.

    On latest zimbra server it work but on old zimbra 8.6 command in step 4.8 simply does not work.

    This is the error:
    ERROR: zclient.IO_ERROR (invoke Connection refused, server: localhost) (cause: java.net.ConnectException Connection refused)

    Any advice.

    Tnx

      1. or email in `cat /backups/zmigrate/emails.txt`; do zmmailbox -z -m $email getRestURL ‘/?fmt=tgz’ > $email.tgz ; echo $email ; done
        This Script is working, but some accounts old mail only is there. updated mail is not coming

      2. if we add -t 0 options still this error is coming ,

        ERROR : zclient.IO ERROR (unable to get ?fmt=tgz) (cause : java.io.IOException chunked stream ended unexpectedly

        After that account maildata is not backed up fully, half the data is there.

  14. Hi, excellent guide. I have already tried in a dev server to see everything works. I’m planning to migrate to a multiserver, from 8.6 to 8.7. I’m going to proceed and backup the mails, and then restore them on the mailstore server of the multi. Ok.

  15. Hi Sherin

    step . 4.8

    for email in `cat /backups/zmigrate/emails.txt`; do zmmailbox -z -m $email getRestURL ‘/?fmt=tgz’ > $email.tgz ; echo $email ; done

    please give me advice & instructions for modify script for backup to only spesific user account

    example ;

    for email in `cat /backups/zmigrate/emails.txt`; do zmmailbox -z -m $user@somedomain.com getRestURL ‘/?fmt=tgz’ > $email.tgz ; echo $email ; done

    thanks

    -dede

  16. Hi Sherin,

    After following all steps configuration. I cannot login to zimbra admin panel with new password or old password admin.
    How to solve this?

  17. Hello,

    for save the status from all users add these lines (Active, locked, lockout, etc) :

    mkdir statuses
    for i in `cat emails.txt`; do zmprov ga $i zimbraAccountStatus|grep zimbraAccountStatus |awk ‘{print $2}’ > statuses/$i.txt ; echo $i; done

    Thanks

  18. Thank you Sherin for this documentation, it worked smoothly for me except for a little itch along the line (probably due to space or unknown character) which was easily resolved without much hassle. The next thing I’m searching is automated backup to a remote server from the primary server.

  19. Hi! Great guide! Thanks. Another fix @ 4.10. mkdir signatures (plural form, not signature).

  20. It is working perfectly. But runing server /opt/zimbra folder size increase double than backup server /opt/zimra that cannot identify. Please give instruction how to check duplicate data and delete.

    Thanks,
    Alamgir

  21. Given the size of our mail server, is there a way to sync the emails after the initial migration? To give an indication, it’s taking approx a week to compress and export all our mailboxes – during this time, the mail server is still running and people are receiving additional messages – the ideal solution would include a way to sync any ‘new’ emails since the original export.

  22. Hi,
    Thanks for your help. I’m having this error:
    ERROR: service.FAILURE (system failure: POST failed, status=500 Server Error)

    when restoring all the email accounts with this script:
    for i in `cat /backups/zmigrate/emails.txt`; do zmmailbox -z -m $i postRestURL “/?fmt=tgz&resolve=skip” /backups/zmigrate/$i.tgz ; echo “$i — finished “; done

    How can we solve this problem? Thanks a lot.

  23. Dear,
    its helpful but i want help that…..when migrating emails …after server change old email again downloaded on outlook or any other mailing software.

  24. Hi thanks for this tuto
    A minor correction
    in the 4.10 script change “mkdir signature” by “mkdir signatures” 🙂

  25. Just one comment :
    after launching the 5.3 command line I get the folowing error
    “ERROR: zclient.IO_ERROR (Read timed out) (cause: java.net.SocketTimeoutException Read timed out)”
    but the script continue and migrate the account normaly.

    I do not see any trouble in the migration…

  26. Another contribution for even more annoying customers/users

    Backup/restore out of office configuration

    Backup:
    #!/bin/bash
    mkdir ooo/
    for i in `cat emails.txt`; do
    zmprov ga $i | grep OutOfOffice > ooo/$i.txt
    echo “OOO for $i done”
    done

    Restore:
    #!/bin/bash
    for i in `cat emails.txt`; do
    ativo=`grep zimbraPrefOutOfOfficeReplyEnabled ooo/$i.txt | awk {‘print $2’}`
    text=`grep zimbraPrefOutOfOfficeReply ooo/$i.txt | sed ‘s/zimbraPrefOutOfOfficeReply: //g’ | grep -v zimbraPrefOutOfOfficeReplyEnabled`
    if [[ “$ativo” == “TRUE” ]] && [[ ! -z “$text”]]; then
    fromdate=`grep zimbraPrefOutOfOfficeFromDate ooo/$i.txt | sed ‘s/zimbraPrefOutOfOfficeFromDate: //g’`
    untildate=`grep zimbraPrefOutOfOfficeUntilDate ooo/$i.txt | sed ‘s/zimbraPrefOutOfOfficeUntilDate: //g’`
    zmprov ma $i zimbraPrefOutOfOfficeReplyEnabled TRUE
    zmprov ma $i zimbraPrefOutOfOfficeReply “$text”
    zmprov ma $i zimbraPrefOutOfOfficeFromDate $fromdate
    zmprov ma $i zimbraPrefOutOfOfficeUntilDate $untildate
    echo “OOO setup for $i done”
    else
    echo “OOO not active for $i”
    fi
    done

  27. Hello,

    Just to let you know that Ive followed the steps previously detailed and it worked perfectly by my side.

    Thank you very much for publishing the post.

    Best regards,
    Manuel Lazo

  28. Hi, first thanks for your work, second i have all my domains whit an external DC how can i backup and restore that, thanks again

  29. Hello,

    Excellent guide, thanks.

    I just have a question, is it possible to dont lose mails received between the data backup (point 4.8), data restore and final dns change?

    Thanks

  30. Thanks a lot Sherin Abdulkhareem. Great work and its working smoothly. Really appriciatable. could you please share one things with me……Mail monitoring queue shows 1 error:
    Message: system failure: exception during auth {RemoteManager: mail.domain.com->zimbra@mail.domain.com:22} Error code: service.FAILURE Method: [unknown] Details:soap:Receiver

  31. when i use this command :

    for i in `cat /backups/zmigrate/distributinlist.txt`; do zmprov gdlm $i > /backups/zmigrate/distributinlist_members/$i.txt ;echo “$i”; done
    and
    for i in `cat emails.txt`; do zmprov ga $i | grep zimbraMailAlias |awk ‘{print $2}’ > alias/$i.txt ;echo $i ;done

    I got a error : error ambiguous….

    u must change and use this syntax :

    for i in $(cat /backups/zmigrate/distributinlist.txt); do zmprov gdlm $i > /backups/zmigrate/distributinlist_members/$i.txt ;echo “$i”; done
    and
    for i in $(cat emails.txt); do zmprov ga $i | grep zimbraMailAlias |awk ‘{print $2}’ > alias/$i.txt ;echo $i ;done

    that’s works for me 🙂

  32. Hi,

    I have an error when running the command:
    for email in `cat /backups/zmigrate/emails.txt`; do zmmailbox -z -m $i getRestURL ‘/?fmt=tgz’ > $i.tgz ; echo $email ; done

    Getting below errors
    ERROR: account.NO_SUCH_ACCOUNT (no such account: getRestURL)
    admin@domainname.in
    ^Ca.sharma@mahagenco.in
    ERROR: account.NO_SUCH_ACCOUNT (no such account: getRestURL)
    abt@domainname.in
    ERROR: account.NO_SUCH_ACCOUNT (no such account: getRestURL)
    acctsparastps@domainname.in

  33. correction
    $i.name replaced with $i
    $i.signarure replaced with $i and the script works.

    for i in `cat emails.txt`; do zmprov ma $i zimbraSignatureName “`cat signatures/$i`”; zmprov ma $i zimbraPrefMailSignatureHTML “`cat signatures/$i`”; zmprov ga $i zimbraSignatureId > /tmp/firmaid; sed -i -e “1d” /tmp/firmaid; firmaid=`sed ‘s/zimbraSignatureId: //g’ /tmp/firmaid`; zmprov ma $i zimbraPrefDefaultSignatureId “$firmaid”; zmprov ma $i zimbraPrefForwardReplySignatureId “$firmaid”; rm -rf /tmp/firmaid; echo $i “done!”; done

  34. Hi Admin,

    Thanks for your tutorial, the tutorial was working fine. But I have some condition:
    1. Distribution list members cannot backup properly (and i found article that give info gdlm not working until ZCS 8.0.3 https://forums.zimbra.org/viewtopic.php?t=13559), so i used this command for i in `cat /mnt/archive/distributionlists.txt`; do zmprov gdl $i zimbraMailAlias zimbraMailForwardingAddress > /mnt/archive/distributionlist_members/$i.txt ; echo “$i”; done (this code can backup distribution list members, but we must make modification on txt file).

    2. When we do step 5.1 (restore all domains), there is a strange that process looks like not responding (we only restore 1 domain), so we cancel the process (ctrl + c) but when we check on web gui admin (https://x.x.x.x:7071) domain appears.

    3. when we do step 5.2 (create accounts and set the old password), the accounts and password has been restore success fully. but when we test login with the old accounts and password we got message username and password not match.

    so can you or somebody help me with this poin 5.2 (we backup zcs 7.1.4 and restore to zcs 8.1.5)? Thanks in advanced.

  35. Hello,
    Thanks for great instruction about migration,
    I have a question about forwardings, my emai accounts have many user specify forwarding to different addresses,
    Can someone suggest how can I do this forwardings migration?

  36. Hello,
    howto export identities / personas?

    zmprov gid

    and then how to import by script?
    Regards
    Frank

  37. Thank you very much indeed for this excellent blog post.

    Have migrated from Zimbra OSE 8.8.15 on a Centos 7 to another machine with Oracle 8 and Zimbra 10 NE.

    All seems to be alright as far as I can see.

Leave a Reply

Your email address will not be published. Required fields are marked *