Objective :
After I installed Zimbra mail server for test, it had domain test.domain.com. Today I want to change current domain and migrate all data from test.domain.com to test.com. Furthermore I want to set email alias from old account to new account too.

Server and Domain Detail:
Server host name (check by command #uname -n) : mail.test.domain.com
Old domain name : test.domain.com (user has email xxx@test.domain.com)
New domain name : domain.com (user has email xxx@domain.com)
Zimbra server version : 5.0.2 (Upgrade from 4.0.9)

Summary steps :
1. Update DNS for support new domain name.
2. Rename domain name.
3. Create old domain by virtual domain.
4. Set alias email from old domain to new domain.
5. Set A record & MX record from your Hosting.

Estimate time : 90 Minutes.

All steps :

1. Smile

2. Stop Zimbra service

3. Backup Zimbra.
# cd /opt
# tar cvfz zimbra20080321.tgz zimbra
4. Start Zimbra Service again.

5. Check Zimbra service
# su - zimbra
# zmcontrol status
5.1 If you found this message :
Host mail.test.domain.com
antispam Running
imapproxy Running
ldap Running
logger Running
mailbox Stopped
zmmailboxdctl is not running
mta Running
snmp Running
spell Running
stats Running
You must delete this file /opt/zimbra/log/zmmailboxd.pid by this command :
# zmcontrol stop
# rm -rf /opt/zimbra/log/zmmailboxd.pid
# zmcontrol start
6. Check Zimbra service again.
# su - zimbra
# zmcontrol status
6.1 If you found this message :
Host mail.test.domain.com
antispam Running
antivirus Running
imapproxy Stopped
nginx is not running
memcached is running
ldap Running
logger Running
mailbox Running
mta Running
snmp Running
spell Running
stats Running
You must run this command (Type 1 line):
# su - zimbra
# zmprov ms mail.test.domain.com zimbraImapSSLBindPort 7993 zimbraImapBindPort 7143 zimbraPop3BindPort 7110 zimbraPop3SSLBindPort 7995
# zmcontrol stop
# zmcontrol start
# zmcontrol status
7. Change DNS and MX Record

* Change Zone from test.domain.com to domain.com in file /etc/named.conf from
zone "test.domain.com" IN {
// for common resolving
type master;
file "test.domain.com.fwd";
allow-update { none; };
};
to

zone "domain.com" IN {
// for common resolving
type master;
file "domain.com.fwd";
allow-update { none; };
};
* Copy file from /var/named/test.domain.com to /var/named/domain.com.fwd
* Edit detail in file /var/named/domain.com.fwd
$TTL 86400
@ IN SOA mail.test.domain.com. root.domain.com.(
2008020500 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS mail.test.domain.com.
IN MX 10 test.domain.com.

IN A 192.168.201.3
mail IN A 192.168.201.3
to

$TTL 86400
@ IN SOA mail.test.domain.com. root.domain.com.(
2008031900 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS mail.test.domain.com.
IN MX 10 mail.domain.com.

IN A 192.168.201.3
mail IN A 192.168.201.3
mail.test IN A 192.168.201.3
8. Reload named config
# service named reload
9. Change domain name from test.domain.com to domain.com
# su - zimbra
# zmprov -l rd test.domain.com domain.com
** -l = LDAP
** rd = Rename Domain

10. Initial Document feature.
# su - zimbra
# zmprov in wiki@domain.com
# zmprov impn wiki@domain.com /opt/zimbra/wiki/Template Template
11. Restart&check status of zimbra service.
# su - zimbra
# zmcontrol stop
# zmcontrol start
# zmcontrol status
12. Create virtual host for domain.com (Admin page)
12.1 Click Domain -> domain.com -> Virtual Hosts
12.2 Create virtual host : mail.domain.com
10. Test send&receive email.

11. Test create/edit/delete document.

12. Create test.domain.com domain by Zimbra Administrator page. (After rename completed, someone may be sent email to xxx@test.domain.com so I will create test.domain.com and set alias email from test.domain.com to domain.com for all user)
12.1 Click Domain -> New
Domain : test.domain.com
Default class of service : default
Domain status : active
12.2 Next
12.3 GAL Mode : Internal
12.4 Authentication mechanism : Internal
12.5 Virtual host : test.domain.com
12.6 Select : Create domain level document space
12.7 Finish
13. Create all user on test.domain.com like domain.com and set forward email from test.domain.com to domain.com. You can create&set forward email by this script :
#!/bin/bash
################################################## ###############################
# File name : ForwardEmailAll.sh #
# Objective : Create alias email fro all user from old domain to new domain. #
# Create : March 20, 2008 #
################################################## ###############################

FromDN=$1;
ToDN=$2;
NUM_ARGU=$#;

HELP(){
echo "Help";
echo "$0 [From doman] [To Domain]";
echo "Example :";
echo " $0 test.domain.com domain.com";
exit;
}

if [ ${NUM_ARGU} -ne 2 ]
then
HELP;
else

for ID in `zmprov gaa ${ToDN} | awk -F'@' '{print $1}'`
do
echo "zmprov ca ${ID}@${FromDN} admin1";
zmprov ca ${ID}@${FromDN} admin1
sleep 1;
echo "zmprov ma ${ID}@${FromDN} zimbraprefMailForwardingAddress ${ID}@${ToDN}";
zmprov ma ${ID}@${FromDN} zimbraprefMailForwardingAddress ${ID}@${ToDN}
done
fi
14. Test send email from domain test.domain.com and check new email in domain domain.com.

15. If you have good solution , please let me know.