Seamless Email Server Migration

March 13th, 2010 Leave a comment Go to comments

Those of you who run your own email servers will likely need to move from server to server from time to time.  It would be nice if you could just change an MX record and have all email instantly arrive at the new server.  Unfortunately, for various reasons, not everyone obeys TTL, and may cache the old MX record for an unknown period of time.  Here's a list of basic instructions for how to migrate your email from one server to another, guaranteeing that no email will fall through the cracks.

  1. Before you start, be sure the new email server is configured exactly as you please.  Make sure that your SPF records are correct and DomainKeys is working.
  2. Change the TTL of your mail server's DNS record to something short like five minutes.  Do this at least the length of your previous TTL before the migration.
  3. Several hours before the migration, disable "Leave mail on server" for any users that use POP3.  (The POP3 clients will download multiple copies of mail left on the server.)
  4. Create all your email accounts on the new server, exactly as they are on the old server.
  5. Create a subdomain on the new server, something like tempmail.example.com.
  6. Create an alias (forwarder) for each mail account on the new server.  If you have an account murphy@example.com, create an alias murphy@tempmail.example.com that forwards to murphy@example.com.
  7. Create an alias (forwarder) for each mail account on the old server.  If you have an account murphy@example.com, create an alias murphy@example.com that forwards to murphy@tempmail.example.com.  This way, any mail sent to the old server during the migration will be forwarded to the new server.  Send an email to murphy@example.com and be sure it arrives in Murphy's account on BOTH servers.

    The next few steps should be done as quickly as possible so that users notice little to no downtime:
  8. Change everyone's email passwords on the old server to something random so that they are no longer able to log in to the old server.
  9. Use rsync or a similar tool to synchronize the mail folders from the old server to the new one.
  10. Change the MX record for example.com so that it points to the new server.
  11. Change any DNS records or redirects to webmail so that they point to the new server.
  12. Change any DNS records for the POP3/SMTP/IMAP servers so that they point to the new server.
  13. Reinstate "Leave mail on server" for POP3 clients, if appropriate.

Congratulations!  If all went according to plan, nobody noticed.
 
  1. No comments yet.
Allowed HTML: <b>, <i>, <em>, <strong>. All other < and > will be replaced with &lt; and &gt;.