Move mail from server A to server B


As I’m setting up my new server, I need to migrate all my ‘clients’.
Doing this might invoke loss of mail, due to the DNS changes, where the user is already on the new server, but some mail is still being sent to the old one.
I’d like to do an rsync the day after the move to sync the remaining files.
I did this for one user already, but it does not seem to have the desired effect.

rsync -iva -e "ssh -p 6000" old_server_ip:/home/oldclient/Maildir/ /home/newclient/Maildir/ chown -R user:user /home/user/Maildir/*

The new server owner has a different name, so we have the following:

old sever: user: oldclient new server: user: newclient
I did some googling, and found the following post:

I fail to see where I can define where the old server is defined.
The change of the server owner has only been done for 1 domain. If this is a problem, I’d still like to know how to use the above script to transfer the mails of other clients.

Thanks so much for any help.


Hmm, at first glance, I don’t see anything that wouldn’t work with what you described above. Are you running into an issue of some sort?

All that said, I’ve had luck using the tool “imapsync” to perform tasks like that in the past, it does a great job of copying new email from one system to another. It works similarly to rsync, but it runs over IMAP and is designed just for copying email.


Hey Eric,

After I moved the Maildir I wanted to see if the mail was really moved.
So I went to a roundcube on the new server (on a different domain) and logged in with the e-mail address of the mail I moved. However, I get the notification that there’s no mail in the inbox.

Anything I could be doing wrong or forgetting?

Thanks for the tip about imapsync. I’ll have a look at it also.

Ah. I think I see what I did wrong.
I moved the files from server A to B, but I did not use the “virtualmin copy-mailbox” command. i will execute a new transfer later today when I have some time.