Dovecot doveadm mailbox copy during live traffic – missing behavior on concurrent updates
0 reputation · 11 Aug 2023, 15:44 UTC
0 reputation · 11 Aug 2023, 15:44 UTC
We need to migrate a small IMAP application from one Dovecot instance to another with no service interruption. The plan is to use doveadm mailbox copy to replicate the entire mailbox hierarchy while preserving UIDs, flags, and subscriptions.
During the copy, the source server continues to receive new messages. The command does not hold a global lock, so concurrent updates may be applied after the copy finishes. The exact timing and handling of these updates are unclear, especially when the source and destination share the same user base.
doveadm mailbox copy is running, does the destination receive that message immediately after the copy completes, or only after a subsequent incremental run?32275 reputation · 11 Aug 2023, 17:14 UTC
doveadm mailbox copy does not capture messages that arrive after the command starts. It takes a snapshot of the mailbox at the moment the command begins and copies only those existing messages. Any new messages delivered while the copy is running are ignored by that invocation and will appear only after a subsequent incremental copy or a synchronization step.
doveadm mailbox copy copies the current set of messages and does not wait for or include concurrent deliveries.Because the copy works from a static snapshot, the destination mailbox will be identical to the source as it existed at the start of the command. Updates that occur during the copy are not transferred automatically; they require a follow‑up synchronization.
doveadm mailbox copy -u user source_mailbox dest_mailbox for each mailbox. This transfers all messages present at the start.dsync -v -u user mirror. This will transfer any messages that arrived during the copy window and bring the destination up to date.doveadm mailbox status -u user mailbox messages on source and destination; the numbers should match.doveadm fetch -u user mailbox mailbox uid (or doveadm search -u user mailbox ALL) on both sides; the highest UID must be identical.dsync -v -u user mirror. If it reports “no changes”, the destination is fully synchronized.If the source and destination share the same user namespace, confirm that the UIDVALIDITY value for each mailbox is identical on both sides. A mismatch would cause the destination to treat existing messages as new after the copy, leading to duplicates. Please verify UIDVALIDITY equality before proceeding; if they differ, you must reset the destination mailbox (e.g., doveadm mailbox exec -u user mailbox mailbox uidvalidity set value) or use a full re‑sync.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.