[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Graceful way to move user's mail from one host to another?



Adam Rosi-Kessel wrote:

I run a small ISP with two hosts. I need to move some user accounts from one
system to another. There will be no DNS change--the accounts are just moving
from subdomain to another.

In the past when I've done this, I've always done an awkward one-by-one
move, where first I rsync the user's home directory over, then I move the
messages from the user's mail spool into a file in their home directory and
immediately put a .forward file in place, re-rsync the home directory, then
on the target system, I go and copy all the messages from the spool file in
their home directory back into the real spool file in /var/mail. (In cases
where I'm also changing DNS, I then implement the DNS change, and the
.forward file on the first host takes care of messages delivered to the old
IP address until the DNS change propagates).

This is the only way I could think of to insure that no mail is lost in the
short time while the transition is taking place.

Is there a more graceful, and ideally scalable, way to do this?

Set up your hosts so that mail will be routed to the correct host/mailbox, also if you happen to be sending from the old host. Then do:
formail -s sendmail user@your.domain < /var/mail/user

Replace "user" and "your.domain" with correct values, possibly add other options to the formail command-line. The sendmail command also comes in the postfix package, and there are probably other packages that has it.

The only adverse effect of this is that there might be one or two newer emails that end up at the very top of the spool-file, rather than at the end. If the user uses pop to fetch the emails, I cannot vouch for how this will look to the user. Probably advice the the user to set their email-client to download and delete from the server as they fetch mail. Also, you might want to add +1 to the formail command-line in that case, to skip the accounting dummy mail that gets put at the very top of the spool-file.



Reply to: