Zimbra to Zimbra Server Migration

The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

as a whole method

Unofficial method (work with 5.0, may work with <5.0): http://www.zimbra.com/forums/migration/22697-zimbra-zimbra-migration-script.html

Official method (only work > 5.0.9) http://www.zimbrablog.com/blog/archives/2008/09/zcs-to-zcs-migrations.html

item to item method

Here is a script that is a modification of the script above for using curl to migrate users between zimbra boxes using imap protocol. It also transfers calendars and contacts from zimbra server to zimbra server. I just started working on it and here is what i have so far. It worked on two servers i just migrated last week, i hope it helps :)

NOTE: Modified perl below: was not using IO::Scalar or File::Path so no need to use; now supports user names with "@" via wget; support for command line arguments; support for SSL imap; support for various input file separators; other samll tweaks - scottp@dd.com.au

#!/usr/bin/perl
use strict;
use warnings;

#############################################################################
# Please make changes below to suit your system and requirements

# NOTE: hard code host1 & host2 - or pass in as first two parameters to script
my $host1=shift; #host1 is Source
my $host2=shift; #host2 is Dest

# NOTE: enable ssl for imapsync
my $imapsync = " -ssl1 -ssl2";

##############################
# NOTE: Do not set these here - they come from userlist.txt
my $user;
my $pass;

my $data_file="userlist.txt";
open(DAT, $data_file) || die("Could not open file!");
while (<DAT>) {
        chomp;
        # NOTE: userlist.txt can have username@domain password (or comma, tab or |)
        ($user,$pass)=split(/[\|\s\t,]+/,$_);

        ##############
        open (TESTOUT, "imapsync --buffersize 18192000 --nosyncacls --subscribe --syncinternaldates --noauthmd5 --host1 $host1 --user1 $user --password1 $pass --host2 $host2 --user2 $user --password2 $pass $imapsync|");
        while (<TESTOUT>){
                print $_;
        }
        close TESTOUT;

        ### get contacts
        open (TESTOUT, "wget --user $user --password $pass https://$host1/zimbra/user/$user/contacts.csv --no-check-certificate|");
        while (<TESTOUT>){
                print $_;
        }
        close TESTOUT;

        ### get calendar
        open (TESTOUT, "wget --user $user --password $pass https://$host1/zimbra/user/$user/calendar.ics --no-check-certificate |");
        while (<TESTOUT>){
                print $_;
        }
        close TESTOUT;

        ### import calendars
        open (TESTOUT, "curl -u $user:$pass --data-binary \@calendar.ics https://$host2/service/home/$user/calendar?fmt=ics --insecure|");
        while (<TESTOUT>){
                print $_;
        }
        close TESTOUT;

        ### import contacts
        open (TESTOUT, "curl -u $user:$pass --data-binary \@contacts.csv https://$host2/service/home/$user/contacts?fmt=csv --insecure|");
        while (<TESTOUT>){
                print $_;
        }
        close TESTOUT;

        ### remove files
        unlink 'calendar.ics';
        unlink 'contacts.csv';
        ###############
}

users and passwords go in a text file userlist.txt in the format: username|password.

With some versions of wget you may need to specify the username and password as command line arguements (ie --http-passwd=thepass --http-user=user@dom.com) instead of in the URL (ie https://usersname:pass@theurl). If you are getting the error Bad Port, then give this a try.

Copy Calendar From One Zimbra User to Another

In this example we will export a calendar called "LPO calendar" from one user to another user and name it "LPO" in the destination account.

  • Export the calendar "LPO calendar" from user SRC_USER:
[root@zimbra ~]# curl -u admin 'https://zimbra:7071/home/SRC_USER/LPO%20calendar?fmt=ics' > LPO.ics
  • Adjust all the meeting organizer addresses. If you don't do this, the destination user will see the appointments, but can not edit them.
[root@zimbra ~]# cat LPO.ics | sed 's/SRC_USER@/DST_USER@/g' > LPO-dest.ics
  • Create empty calendar in destination user account.
[root@zimbra ~]# su - zimbra -c 'zmmailbox -z -m DST_USER createFolder --view appointment /LPO'
  • Import modified ical data into new calendar.
[root@zebra ~]# curl -u "admin" --data-binary @LPO-dest.ics 'https://zimbra:7071/home/DST_USER/LPO?fmt=ics'


Copy All Messages, Contacts, Calendars, and Mail Filters

I have written a script, which can be run in batch, to copy user data between servers or between mailboxes. This will copy contacts and calendars from every folder no just /Contacts and /Calendar. I used this script two times to copy pretty much everything important when migrating from 4.5.8 to 5.0.2. It doesn't support shared folders, task lists, documents, briefcase, and some other things (I recreated shared folders manually with zmmailbox) but support could be added given enough motivation :)

ZCS Tools currently contains these Migration scripts written in Python/Bash. These scripts are packaged as zimbraMigration-0.x and require imapsync to be installed.

Import distribution list

I wrote a simply bash script to migrate distribution lists from one Zimbra server to another it creates a provisioning script for each list.

myPath=$(pwd)
/opt/zimbra/bin/zmprov gadl | while read listname;
do
   echo "/opt/zimbra/bin/zmprov cdl $listname" > $myPath/$listname
   /opt/zimbra/bin/zmprov gdl $listname | grep zimbraMailForwardingAddress >  $myPath/$listname.tmp
   cat $myPath/$listname.tmp | sed 's/zimbraMailForwardingAddress: //g' |
   while read member; do
     echo "/opt/zimbra/bin/zmprov adlm $listname $member" >> $myPath/$listname
   done
   /bin/rm $myPath/$listname.tmp
done
Jump to: navigation, search