A cPanel-to-cPanel mailbox migration that just copies the maildir is a partial migration. The messages move, but Seen, Flagged, Deleted, and any custom labels live in Dovecot’s index files — which are tied to UIDs and don’t transplant cleanly. After the cutover, the user opens their inbox and every message is marked unread. For a power user with thousands of messages, that’s a workday of re-classification. A proper migration preserves the flag state.
What’s happening
Maildir stores messages as files in cur/, new/, and tmp/ directories. Per-message flags are encoded in the filename (the :2,FRS suffix indicates Flagged, Recent, Seen). Dovecot also keeps an index that adds custom labels and tracks deletes. A naive rsync of the maildir preserves the on-disk flags but doesn’t transfer the Dovecot index — and on the new host, Dovecot rebuilds the index from the maildir, which works but loses custom labels and changes UIDs.
How to verify
Look at the source mailbox’s maildir layout:
ls -la /home/<user>/mail/<domain>/<user>/cur/ | head
ls /home/<user>/mail/<domain>/<user>/dovecot.* 2>/dev/null
Confirm whether the user has custom labels or flag patterns by spot-checking filenames — :2,RS means Recent+Seen, :2,FRS means Flagged+Recent+Seen, :2,a means custom keyword ‘a’.
The fix
-
Use
doveadm syncbetween the two cPanel hosts — it’s the supported, flag-preserving migration tool. From the destination host:doveadm sync -u user@example.com remote:imap://user@example.com:portThis pulls the source mailbox and replicates flags, custom labels, and UIDs into Dovecot’s index on the new host.
-
Configure the source mailbox to allow doveadm access (admin user with the right ACLs) or use IMAP credentials in the sync URL.
-
Run a first sync while the source is live, then a delta sync during the cutover window. The delta picks up anything new since the first sync — minimizing the downtime.
-
Verify on the new host by mounting the user’s account in a test mail client. Flags should be preserved. Custom labels should appear. UIDs may differ — for some clients that means a re-download, but the flags and labels survive.
-
For very large mailboxes, consider a
doveadm backupanddoveadm restorepair instead of sync — those use Dovecot’s own dump format and are slightly faster for one-shot moves. -
Don’t use
rsyncalone for production-quality migration. It loses too much state. Save rsync for read-only archives and edge cases where you accept the loss.
For environments where mailbox-by-mailbox migration is part of a larger move and the flag preservation matters to power users, Stack Harbor runs the migration as part of migration projects.