Search

Thursday, December 02, 2010

IMAP Migration

We helped a customer to migrate dovecot IMAP from one FC13 to another.
 
In the first place, we have to prepare a working sendmail and dovecot environment in the new server.
 
Then migration takes place as follows.
Copy accounts
---------------------
Since UNIX email accounts are kept in /etc/passwd, we can setup accounts in new server by copying required entries from passwd, group, gshaow and shadow.
 
-rw-r--r-- 1 root root 15501 Nov 29 09:24 passwd
-rw-r--r-- 1 root root 5261 Nov 25 14:55 group
---------- 1 root root  3986 Nov 25 14:55 gshadow
---------- 1 root root  2224 Nov 25 14:55 gshadow-
---------- 1 root root 10622 Nov 29 09:24 shadow
---------- 1 root root  5331 Nov 25 14:55 shadow-
Just copying the whole file would not work as it easily leads to conflicts of system accounts in the new server.  We have to make sure that only the user accounts are being copied.
 
Stop sendmail and dovecot in the source machine
----------------------------------------------------------------------
Before actual migration of imap folder and mbox files, we'd better stop the sendmail and dovecot daemons in the source machine to avoid further updates to the mailboxes during migration.
 
# service stop sendmail
# service stop dovecot
 
 
Copy ~/<user> and /var/mail/<user>
--------------------------------------------------
Our client is using both imap and pop3 to manage emails. 
 
The imap index is kept in ~/<user>/mail and pop3 mbox is in /var/mail/<user>.  After the sendmail and dovecot daemons are stopped, we can safely copy these files to the new server.  Remember to preserve the same file permissions in the new server.
 
It is a good idea to copy the whole home directories to the new server to avoid missing .forward, .procmailrc  or other user-specific configuration files.
 
 
Live run
------------
After the home directories and mboxes are restored, the new server is ready for live run. 
 
The most straightforward way is the new server taking up the ip address of the old one as follows.
- shutdown the old server
- modify /etc/hosts and /etc/sysconfig/network-scripts/ifcfg-eth0 (assuming that your ip is bind to eth0)
- service restart network
 
Then we will find mail clients connecting to the new server.
 
 
 
 
Issues that might happen
-----------------------------------
1.OE client re-downloads everything after new mail server is used
 
It might happen if the new server is configured to use a different uidl format from the old one.  Look for the entry "pop3_uidl_format = " in dovecot.conf in both machines to make sure they are the same.
 
2.Size of /var/mail
 
Some users tend to keep copy of messages on server and it would end up in large mbox file in /var/mail.  Regular monitoring or housekeeping on /var/mail is recommended.
 
3.MX priority
 
If we could not keep down time short, we need to setup 2nd MX such that incoming emails are queued there while the primary MX is down and pushed back after our migration completes.
 
 

No comments:

Post a Comment