How to transfer emails between servers (if it's possible)

I moved my websites from a server to another, using the backup and restore procedure, then I changed the DNS record to point the new server IP.

After that, all works very well… but I have a problem. Unfortunately I forgot to disable the old server, and a couple of users have received some emails that now reside on the old server.

There is a way to “move” only these emails from the old server to the new one? I can’t do again a backup since the new server has received, in the meantime, some emails…

Any idea?

Thank you in advance to helping me in solving this problem.


I suppose the easiest way to do that would be to create IMAP accounts for both the old and new server in an email client, and use IMAP’s trans-server copy feature to pull the mails over.

Thank you for the answer. If no one other solution it’s possible, I can try to do this… but there isn’t any way to “copy” or “export” an email from the new server and “paste” or “import” it on the new one?

If there is a way but is not a virtualmin feature, but a postfix feature or something similar, it’s OK for me.


Postfix wouldn’t have a feature for that, nope, because it’s responsible for accepting mail and putting it into mailboxes; it has no features to access mailboxes, read or export emails.

So if you were to look for something aside from Virtualmin’s backup functions (which indeed would overwrite all emails on your new server), you’d look in Dovecot, which is responsible for POP3, IMAP and so on.

But as far as I know, Dovecot doesn’t have export-import features as well. IMAP is quite suitable for that though; there are Linux scripts (e.g. “imapcopy”) that automate the process of transferring mails between IMAP servers. I think that’s as comfortable and automatic as you can get for your purpose…

Ok, thank you very much.


If there aren’t many accounts where this occurred, using Outlook or a similar client may really be one of the simplest ways to handle that.

I’m also a pretty big fan of the imapcopy tool that Locutus mentioned :slight_smile:

But some additional options for you –

You could always generate a new Virtualmin backup for that domain, but only include home directory files in that backup. That backup would then include all new email (since emails are just files in the home directory).

However, if your users have moved emails into different folders (or if any other things have been changed), that would all be undone.

Note though that this will not impact new emails on the new server. Restoring a backup, by default, does not delete files. It will overwrite files if they exist, but it does not delete files that don’t exist on the old server.

If you opt for that, it wouldn’t hurt to generate a set of backups of Virtualmin backups from your new server, just in case :slight_smile:

Another alternative is that you could just copy any files that exist in the $HOME/Maildir/new directory to the same directory your new server. That folder contains all the new emails that have come in for that user.


Thank you very much, Eric… I wasn’t aware that the backup doesn’t delete files… it’s a great thing.

I’ll try to use this method.

Out of curiosity… even though I know it’s a bit OT in this topic… :

I’ve scheduled regular backup of my sites: once a week I perform a full backup and the others 6 days an incremental backup. If I well understood, the incremental backup is (in reality) a differential backup, since the system considers the difference between the current situation and the situation at the last full backup…it’s right?
In that case, my expectation is to have a growing incremental backup, during the week and until I don’t perform a full backup… but this is not always truth… sometimes the incremental backup size is smaller than the incremental backup size of the day before.

Last question: if I manually perform a full backup in the middle of the week, the subsequent scheduled backups consider this backup or the last full scheduled backup?

Thank you again for the support.


You’re right, Virtualmin’s backups are differential, and incorporates all changed files since last full backup. An incremental might be smaller than the previous one if files that were added or changed since the last full are deleted.

Subsequent incrementals will always consider the last full, due to the way it’s coded, no matter if scheduled or manual.

Ok, all is more clear now… thank you very much, guys, for all answers.

Have a nice day.