How to migrate a small handful of users from one mail server to another

dovecotmigrationpostfix

Here's my situation:

I've got a mail server, we'll call it mail1.site.com. And what I want to do is, build a new mail server, mail2.site.com, and migrate all the users over. The setup is Postfix+Dovecot on both. Normally if it's just me, I'll just set up the new server, and go into my mail client and drag my messages over and have it move my messages that way. But if I have a handful of users, I can't expect them all to be savvy enough to do this for every folder in their account.

Does anyone have advice on how to migrate? Is it safe to tar all the thousands of emails in /var/vmail and then just move that over and untar it? I'm open to suggestions.

Best Answer

Is it possible migrate this all at one step with service downtime?
If yes you can tar/untar. But better way is rsync mailbox on the fly, and at service downtime you do rsync again for update.

look at mailqueue, this should be empty. smtp mustn't accept any mail at downtime. but usually you have different situation. mail queue keeps email that cannot send. you can view this email. you decision you leave this emails, or migrate to new server. I found procedure here: http://abhijit.name/articles/configuration/moving_or_restoring_postfix_queue.html

copying mailboxes on the fly has one adventage. you can silently test for specified user, all is ok or not. you'll see moved mailbox or not.

read rsync manual very carefully. test it for one mailbox, it sync only needed information, or rewrite all. use proper options.

Worse situation is when you cannot do some breakdown service, then you should migrate mailboxes user by user. Then you should prepare aliases for both servers. Both should accept emails for both names, but internally redirect email to proper server using aliases behavior. When you'll migrate lat user, you should point MX only to new server and wait until mailqueue on old will empty, and power down this.

If you never have done it, better do any tests on any virtual copy with some set of mailboxes. then you'll increase chance, no one will visit you equiped with sharp fork and burning torch :)