The man doveadm-sync
pages are cryptic and not very well explained, as well they are missing quality real-world examples.
This gist aims to give some clarity and explanation.
Here is the command I got to successfully transfer (and sync backwards too) an email account from an old Dovecot email server to a new Dovecot email server:
To my knowledge, both servers must have a matching account already setup for this to work:
- Old Dovcot server: email account
[email protected]
setup, used and populated with emails. - New Dovecot server: email account
[email protected]
also setup, possibly empty, awaiting email migration from old server.
YMMV - lemeknow
Hint: you have to create/use an ssh key-pair with ssh-keygen
, transfer the contents of the ....pub
key into the new mail server's ~/.ssh/authorized_keys file before this can run.
!!! WARNING: MAKE A BACKUP OF ANYTHING YOU'RE NOT WILLING TO LOSE !!!
This must be run on the server that contains the transferable account and email data (old server):
doveadm -Dv sync -u [email protected] ssh new.mail.server.com -i /path/to/.ssh/privatekeyfor_new.mail.server.com_rsa doveadm dsync-server -u [email protected]
doveadm -Dv
: run with verbose and progress indicator.sync
: sync both ways if email is on both servers (otherwise, just old to new).-u [email protected]
: sync this ONE email address (don't bork all emails in case something fails).ssh new.mail.server.com -i /path/to/.ssh/privatekeyfor_new.mail.server.com_rsa
: This will ssh into new server using the setupssh-keygen
private key file above (see hint above).doveadm dsync-server -u [email protected]
: (from my understanding) ssh runs this part of the command on the new remote dovecot server to get this whole thing working. This is where I spent most of my time experimenting. It would be great if theman doveadm-sync
pages expanded better on this in simple details and included more examples.
I hope this saves someone time.
You're welcome.
—Maui
MIT license: This gist, and everything in it comes with absolutely no warranty!
Very helpful, Thank you!