I am trying to synchronize two mailboxes which reside in different servers. This is due to a migration process. The old server is a courier server and needs to be accessed via IMAP, whereas the new server is a dovecot server. I am trying to follow the original Dovecot documentation. Unfortunately it is not specified where the configuration of the source IMAP needs to be set, when the doveadm
script is run on the destination server. The documentation provides the settings, but does not mention which dovecot configuration file the settings have to be entered.
![](../../users/profiles/142591.webp)
- 233
- 2
- 8
4 Answers
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.
![](../../users/profiles/456321.webp)
- 71
- 1
- 1
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.
![](../../users/profiles/127819.webp)
- 5,400
- 10
- 52
- 91
-
Hi. Thanks for the hint. I have also considered using imapsync. But I have read ( http://wiki2.dovecot.org/Migration ) that it does not preserve the UID of the e-mails. If UIDs are not preserved, the IMAP clients which are already bound to the first server, when they are pointed to the new server, will not be able to sync with the local cache and have to download all (thousands) of messages from scratch. I would therefore like to stick to the original documentation, which is albeit a bit unclear – lefterav Jun 18 '14 at 12:11
-
Sorry but I was unable to understand this. IMAPSync does not care about UID. It works on the IMAP layer, so the UID's are defined at your server by you at the account creation processes. – Vinícius Ferrão Jun 18 '14 at 16:09
-
Exactly. IMAPsync does not care about UIDs, but clients like Thunderbird do. It is clearly said here: http://wiki2.dovecot.org/Migration#IMAP_migration "When migrating mails from another IMAP server, you should make sure that these are preserved: If UIDs are lost, at the minimum clients' message cache gets cleaned and messages are re-downloaded as new. Some IMAP clients store metadata by assigning it to specific UID, if UIDs are changed these will be lost.". The solution is to use doveadm but I don't understand how. – lefterav Jun 19 '14 at 14:23
-
I don't get the point of UID mapping. But I've updated my answer to fit your needs. – Vinícius Ferrão Jun 20 '14 at 04:41
-
I would also like that the messages in the new server also have the UUID they used to have in the old server. This is not provided by --useuid I think, according the description – lefterav Oct 24 '14 at 15:37
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 = %u@company.com
imapc_password = mypassword
imapc_features = rfc822.size fetch-headers
imapc_port = 143
pop3c_host = pop3host.company.com
pop3c_user = %u@company.com
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.
![](../../users/profiles/184509.webp)
- 742
- 5
- 17
-
The Dovecot documentation page [Migrating mailboxes](https://doc.dovecot.org/admin_manual/migrating_mailboxes/#migrating-mailboxes-over-imap) has more examples on creating this file. – Paul Jan 31 '22 at 19:59
You need to include those settings in Dovecot configuration,
usually Dovecot configs are in /etc/dovecot/
.
Best would be to place the configuration in /etc/dovecot/conf.d/90-migration.conf
(all files in conf.d
dir are automatically included).
To reload the config you need to run:
sudo doveadm reload
![](../../users/profiles/36982.webp)
- 1,431
- 3
- 19
- 28