christoph ender's

blog

saturday the 12th of august, 2023

strict versus real-strict imapsync

imapsync is an extremely useful tool for the migration of imap accounts. While trying to migrate accounts with a very large number of messages, I encountered a few warnings about duplicates. The imapsync FAQ says the it's a problem with message identification – imapsync by default uses the Message-ID: and Received: headers to identify messages on both sides, which may fail when, for example, imap servers change one or more of these headers.

The easiest solution for my sync task – which was to migrate all the accounts to a fresh set of servers, which haven't been active before – was to switch to --useuid. This will make imapsync identify messages by the imap UIDs instead of the headers mentioned above.

This may not solve the problem immediately in case imapsync has been run before without having the --useuid set. One possible solution – the FAQ has way more details – is to set the --delete2 flag, which will remove any messages from the destination which aren't present in the source account.

Also, syncing hundreds of thousands of messages takes some time. Setting the --usecache parameter helps a great deal: for every transfer, imapsync creates a cache file in /tmp, which greatly speeds up subsequent imapsync runs. This will allow you to run the initial syncs during production and keep the downtime for the actual migration to a minimum.