Remember Steven Jobs  • • •  Zimbra Empty Mailbox Detector       all posts in Archive

Migrate Zimbra from 32bit to 64bit

Trying to migrate 32bit Zimbra Mailbox to 64bit Zimbra. You can migrate LDAP data first which including all the accounts and then migrate Mailbox which including messages, calendars ... etc

I assume you using the same version of Zimbra with both 32 bit and 64  bit. But it should be able to work for all version > 6.0

Migrate LDAP Data

 

On 32 bit Zimbra : 

Export LDAP data in 32bit Zimbra
su - zimbra
/opt/zimbra/libexec/zmslapcat /tmp/
chown username:username /tmp/ldap.bak

On 64 bit Zimbra:

Copy the LDAP data to 64bit Zimbra
scp -P 32 <username>@<64bit zimbra>:/tmp/ldap.bak /tmp/ldap.bak
Replace the old hostname with the new one
sed -i 's/<32bit zimbra name>/<64bit zimbra name>/g' /tmp/ldap.bak
Backup LDAP passwords
su - zimbra
zmlocalconfig -s | grep password > /opt/zimbra/backup/zmlocalconfig-pass.txt
zmcontrol stop
Backup LDAP database and then empty it
mv /opt/zimbra/data/ldap/hdb/ /opt/zimbra/data/ldap/hdb.backup/
mkdir -p /opt/zimbra/data/ldap/hdb/db/
mkdir -p /opt/zimbra/data/ldap/hdb/logs/
cp /opt/zimbra/data/ldap/hdb.backup/db/DB_CONFIG /opt/zimbra/data/ldap/hdb/db/.
exit
Import the LDAP database from the old environment
/opt/zimbra/openldap/sbin/slapadd -q -b '' -F /opt/zimbra/data/ldap/config -cv -l /tmp/ldap.bak > /var/log/zimbra-ldap-import.log
chown -R zimbra:zimbra /opt/zimbra/data/ldap/hdb/db/
Restore LDAP passwords
su - zimbra
zmldappasswd $(grep zimbra_ldap_password /opt/zimbra/backup/zmlocalconfig-pass.txt | cut -d= -f 2)
zmldappasswd -r $(grep ldap_root_password /opt/zimbra/backup/zmlocalconfig-pass.txt | cut -d= -f 2)
zmldappasswd -p $(grep ldap_postfix_password /opt/zimbra/backup/zmlocalconfig-pass.txt | cut -d= -f 2)
zmldappasswd -a $(grep ldap_amavis_password /opt/zimbra/backup/zmlocalconfig-pass.txt | cut -d= -f 2)
zmldappasswd -l $(grep ldap_replication_password /opt/zimbra/backup/zmlocalconfig-pass.txt | cut -d= -f 2)
zmldappasswd -n $(grep ldap_nginx_password /opt/zimbra/backup/zmlocalconfig-pass.txt | cut -d= -f 2)
zmcontrol start

 

Migrate Mailbox Data

Here we write bash script to use the zimbra export and import tool.

On 32 bit Zimbra : 

Mailbox Export Script
#!/bin/bash
### START CONFIGURATION ###
DIR="/zimbra-mailbox-backup";
### END OF CONFIGURATION ###

USERS=`su - zimbra -c 'zmprov -l gaa'`;
DATE=`date +%Y%m%d`;

if [ ! -d $DIR ]; then mkdir $DIR; chown zimbra:zimbra $DIR; fi

for ACCOUNT in $USERS; do
NAME=`echo $ACCOUNT`;
echo "Processing mailbox $NAME backup..."
su - zimbra -c "zmmailbox -z -m $ACCOUNT getRestURL '//?fmt=tgz' > $DIR/$NAME.tgz";
done

echo "Zimbra mailbox backup has been completed successfully."

On 64 bit Zimbra : 

Mailbox Import Script
#!/bin/bash
### START CONFIGURATION, CHANGE THE FOLDER WITH YOUR BACKUP FOLDER ###
DIR="/tmp/zimbra-mailbox-backup";
### END OF CONFIGURATION ###

clear

echo "Retrieve zimbra user name..."

USERS=`su - zimbra -c 'zmprov -l gaa'`;

for ACCOUNT in $USERS; do
NAME=`echo $ACCOUNT`;
echo "Restoring $NAME mailbox..."
su - zimbra -c "zmmailbox -z -m $NAME postRestURL '//?fmt=tgz&resolve=reset' $DIR/$NAME.tgz";
done
echo "All mailbox has been restored successfully"