Migrating from any IMAP/POP3 server to Dovecot
You can also do the following on the command-line without configuration files:
# doveadm -Dv \
-o imapc_host=<SOURCE_HOST> \
-o imapc_user=<SOURCE_USERNAME> \
-o imapc_password=<SOURCE_PASSWORD> \
-o imapc_features=rfc822.size \
-o imapc_ssl=starttls \
-o mail_fsync=never \
backup -R -u <DESTINATION_MAILBOX> imapc:
I had great problems, because my source IMAP only supports STARTTLS on port 143. -o imapc_ssl=starttls
was a life-saver in my case.
You can make a sync after the initial backup with:
# doveadm -Dv \
-o imapc_host=<SOURCE_HOST> \
-o imapc_user=<SOURCE_USERNAME> \
-o imapc_password=<SOURCE_PASSWORD> \
-o imapc_features=rfc822.size \
-o imapc_ssl=starttls \
-o mail_fsync=never \
sync -1 -R -u <DESTINATION_MAILBOX> imapc:
Of course, this is quite insecure if you have more users on the box that can see your commands (and passwords) with who
or by looking into your .bash_history file, so beware.
If the two mail servers are running without problems with the IMAP protocol I would use imapsync
to do the job. Both Courier and Dovecot are supported by imapsync
.
It's really straightforward to use and support many features, like regexp mappings for different folder synchronisation.
The software is FOSS and can be found here: http://imapsync.lamiral.info
If you need the UID sync you can add the option --useuid
in the imapsync. I'm not sure if you're talking about this kind of UID. But this is the option that you should be looking for:
--useuid : Use uid instead of header as a criterium to recognize messages. Option --usecache is then implied unless --nousecache is used.
You should migrate your mail using the dsync
utility from Dovecot. This will preserve the UIDs and even POP3 UIDLs if necessary.
Run dsync
using the backup -R
option, to 'reverse backup' from the remote IMAP server to the local Dovecot server. You need to have a special configuration file created, something like this:
imapc_host = imap.company.com
imapc_user = %[email protected]
imapc_password = mypassword
imapc_features = rfc822.size fetch-headers
imapc_port = 143
pop3c_host = pop3host.company.com
pop3c_user = %[email protected]
pop3c_password = mypassword
pop3c_port = 110
namespace pop3c {
prefix = POP3-MIGRATION-NS/
location = pop3c:~/pop3c
list = no
hidden = yes
}
!include /etc/dovecot/dovecot.conf
plugin {
pop3_migration_mailbox = POP3-MIGRATION-NS/INBOX
pop3_migration_skip_size_check = yes
pop3_migration_ignore_missing_uidls=yes
}
mail_prefetch_count = 20
mail_shared_explicit_inbox = no
protocol doveadm {
mail_plugins = $mail_plugins pop3_migration
}
Note this is for a single user; you may want to have different options if you use a master user/password, or if you require SSL for the connections.
Then call it with something like:
dsync -D -v -u username -c configfile.cfg
The username
replaces the %u
in the config.cfg
file. The -D -v
is verbose debug mode.