I struggled with this at one time, and with the lack of examples around the internet. In fact, I might have written this very post myself at one point! In the end, the penny dropped when I saw that the format was
(command on local server) + (stuff you need to connect over ssh) + (command on remote server)
So what worked for me was:
doveadm backup -u user@domain.com
ssh -p 2222 (+ other ssh options) root@remoteserver.com
doveadm dsync-server -u user2@domain2.com
If you get dsync-remote(user2@domain2.com): Error: Mailbox INBOX sync: mailbox_delete failed: INBOX can't be deleted ... you'll need to clear the remote directory first! Or maybe try sync instead of backup?
I found that running as root on the remote server was necessary in my case, due to the permissions on the remote directory. You might want to check permissions on remote directory are writable by the user in your ssh command.
If still no joy you can run doveadm user user@domain.com on your local server and doveadm user user2@domain2.com on your remote server and dovecot will tell you where its synching from and to.
Finally, this solution is a 'push' from source server to target. You may 'pull' the other way if that makes more sense in your environment with -R
Those pieces were enough for me to get it to work ...
P.
PS. For the record, on the original job I was under time pressure, and yes, I did use imapsync to get it done in the end. I got this to work later on when I had more time to tinker.
On 14/05/2020 09.09, Gregory Sloop wrote:
So I've done quite a lot of searching on the list and on the web - and perhaps my google-fu is really bad - but I can't find any real recipes on how to sync mail from the old server to the new.
As an FYI - the old server is a CPanel/WHM setup on a VPS. The new is mailcow - which uses docker.
However, I don't think either of these platforms is what's causing the issue - but I'm certainly not sure of that.
I've tried several things - but have lost track of all the things I've tried. This seemed like the best of all the things I've tried.
This particular mailbox/user+domain is setup on both servers.
doveadm backup -D -u mc-user@abc.net ssh root@abc.net -p2200 doveadm dsync-server -u cp-user@abc.net
mc-user@abc.net is the MC/NEW mailbox/domain cp-user@abc.net is the CPanel/OLD user/domain account The SSH server of the remote system is running on port 2200.
However when I try this, I get: WARNING: The WATCHDOG_NOTIFY_EMAIL variable is not set. Defaulting to a blank string. dsync-local(user@abc.net)<v44NFyRWvF5efgAAb6OASA>: Error: read(remote) failed: EOF (version not received) doveadm(user@abc.net): Fatal: execvp(ssh) failed: No such file or directory
The process appears to hang, and a Ctrl+C stops it.
I'd love to get pointed at a reasonable recipe on how to make this work.
I don't really get/understand the docs much at all. [And either everyone else understands it just fine, and never thinks to write a document on how to do it - or, and I think this is a lot more likely - they're using something like imapsync to do it. I found numerous places where others were, essentially, "Dovecot's tool is way too complicated and I can't get it to work right, so I used imapsync." I suppose I should probably just do that too, but it does seem a shame to do that when the dovecot tool is almost certainly the best tool for the job, but I can't figure out how to use it.]
If someone can help me grok what's going on, I'm glad to write it up for the list and or a blog entry so it's more accessible.
TIA -Greg