Migrating Email Accounts on FreeBSD

In: Howtos

18 Aug 2009

I’ve been busy the past few weeks consolidating servers. We have some really old servers from one of our VPS providers that really needed to be decommissioned. The problem with a project like this is that the older they are, the more stuff is built into it – crons, url rewrites, custom DNS, the list goes on. And since these are working sites, we could not afford downtime and each migration needed a few undisturbed hours.

One of the major task was to migrate email accounts from our legacy VPS running FreeBSD 4.7 to newer ones running 6.3. Here’s how I did it.

  1. Copied the passwords from /etc/passwd in the older 4.7 servers.
    (Copy the part right after the name until right before the colon – e.g. mike:54YBKHNIE0.3L: ) UPDATE: Someone suggested a utility called ‘vipw’. Haven’t tried it yet.
  2. Pasted them into /etc/master.passwd of new server.
    (Create the users you need first with any temp password. The paste the one above between the name and colon)
  3. Ran pwd_mkdb -p /etc/master.passwd
  4. Updated the MX and A record for the mail server to point to the new server. We normally migrate email and web separately to minimise downtime. Using a good DNS service like DNS Made Easy allows you to set a low TTL for these changes to take affect quickly.
  5. Finally, I commented out the hostname in /etc/hosts on the old server to tell it that it no longer manages emails for this domain.
  6. Finally finally, I forwarded old emails using Mutt to the new account.

Hope this helps, worked wonders for us. Clients had no disruption to their emails which meant little grief for me!

Comment Form

About VPS Guides

I've been using Virtual Private Servers for the past 11 years. I'd like to share these experiences here, so I'll be writing Tips, Tutorials, Guides and other helpful hints...

» VPS Hosting Comparison Chart «

  • admin: Haha... yes. I think I might have published this one a little too early, I've been compiling but hav [...]
  • unmetered vps: So uhm.. where is the comparison? [...]
  • tayfun: thanks for the hint. I have been searching this dns stuff and i was about to get crazy :) [...]
  • Infrenion: Nice post, I would recommend using WHMCS Billing system (http://www.whmcs.com) and Vision Helpdesk S [...]
  • michael: Thanks. This helped me. You know how frustrating these simple things can be!! [...]
DNS Made Easy

Partner Sites