DOVEADM-SYNC(1)
π DOVEADM-SYNC(1) π
Dovecot manual page, bestie. Yes, the whole DOVEADM-SYNC(1) vibe. Let's get into it.
β¨ NAME β¨
doveadm-sync β Dovecot's two-way mailbox synchronization feature π
π¬ SYNOPSIS π¬
doveadm [GLOBAL OPTIONS] sync [-u user | -A | -F file | --no-userdb-
lookup] [-S socket_path] [-1fPR] [-l secs] [-r rawlog path] [-m mailbox]
[-g mailbox guid] [-n namespace | -N] [-x exclude] [-a all mailbox] [-s
state] [-T secs] [-t start date] [-e end date] [-O sync flag] [-I max
size] [-p setting=value] destination
doveadm [GLOBAL OPTIONS] backup [-u user | -A | -F file | --no-userdb-
lookup] [-S socket_path] [-fPR] [-l secs] [-r rawlog path] [-m mailbox]
[-g mailbox guid] [-n namespace | -N] [-x exclude] [-a all mailbox] [-s
state] [-T secs] [-t start date] [-e end date] [-O sync flag] [-I max
size] [-p setting=value] destination
π«Ά DESCRIPTION π«Ά
Okay so dsync (short for doveadm sync) is Dovecot's mailbox synchronization feature. It can be used for several different use cases: Two-way synchronization of mailboxes, creating backups of mails, and convert mailboxes from/to different mailbox formats. All of these can be used within the same server or between different servers (via ssh(1) or tcp connections). Remote mailboxes can be accessed also via IMAP protocol, which allows using dsync for mailbox migration purposes. π
You can run dsync in one of three modes:
doveadm backupβ performs one-way synchronization. If there are any changes in the destination they will be reverted, so the destination will look exactly like the source. πdoveadm syncβ performs two-way synchronization. It merges all changes without losing anything. Both the mailboxes will end up looking identical after the synchronization is finished. β¨doveadm sync -1β performs one-way synchronization. If there are any changes in the destination, they will be preserved and the new changes will be merged on top of them. This merging doesn't currently work perfectly, so its use should be limited. Its main purpose is that during mailbox migration you can rundoveadm backupmultiple times, then switch mails to be delivered to the new mailbox and rundoveadm sync -1once more to transfer any last new mails from the old mailbox. π- The one-way algorithm is the same as two-way dsync algorithm except the source account is not modified. It fetches the message's GUID (Global UID), which is used to identify any conflicting UIDs in messages. As long as the source and destination side has matching
UID<->GUIDmapping, those emails are assumed to be synced correctly. Only after the first mismatch will changes begin. π¦
- The one-way algorithm is the same as two-way dsync algorithm except the source account is not modified. It fetches the message's GUID (Global UID), which is used to identify any conflicting UIDs in messages. As long as the source and destination side has matching
Example: Source mailbox has messages UID 1..5; source mailbox is synchronized using doveadm backup to the destination. Subsequently, UID 6 is delivered to the source mailbox and UID 1 is expunged from the destination mailbox. In this example, UID 1 is kept removed (in destination) because UID 1..5 have identical Date+Message-ID headers. UID 6 is not seen in destination so it's copied.
If both source and destination have UID 6, but the messages are different, the headers don't match and both the messages are kept in the destination but they're given new UIDs 7 and 8 just to be sure any client didn't get confused about what UID 6 actually was. Thus, one-way sync begins to quickly diverge from the source mailbox once changes start to occur on either side; one-way sync should therefore normally only be used within a short period of time after a doveadm backup or doveadm sync command was used to synchronize the mailboxes. π
There are also three different synchronization algorithms:
- Full synchronization (
-fparameter) β scans through all the messages in all the mailboxes. This guarantees that everything will be synchronized, but it's unnecessarily slow for incremental synchronization. π’ - Fast synchronization (default) β first attempts to find mailboxes that have changed, and synchronize only those. This is done by checking the mailboxes' metadata (
NEXTUIDandHIGHESTMODSEQ). Usually this works fine, especially with one-way synchronization, but if both sides do exactly the same number of changes, the metadata may end up containing the same values even if the changes were different. π₯ - Stateful synchronization (
-sparameter) β is the most efficient way to synchronize mailboxes. It relies on having the earlier dsync run's state saved somewhere and being passed to the next dsync run. Based on this state dsync can send only the changes that happened after the previous dsync run. As long as the state or the mailboxes aren't corrupted this algorithm should work perfectly. π
The syncing is done as perfectly as possible: an IMAP or a POP3 client shouldn't be able to notice any differences between the two mailboxes. Two-way syncing means that it's safe to do any kind of modifications in both sides, and dsync will merge the changes without losing any changes done on either side. This is possible because dsync can access Dovecot's index logs that keep track of changes. It's of course possible to have conflicts during merging, these are resolved in a safe way. See the dsync design document for more information. π
dsync uses the same configuration files as the rest of Dovecot (via doveconf(1)). The entire configuration can be changed by giving -c parameter to another configuration file, or using -o parameter to override specific settings. When executing a remote dsync program it works the same way: it uses its own local configuration. βοΈ
dsync can be run completely standalone. It doesn't require any Dovecot server processes to be running, except when using -u parameter to do a userdb lookup from auth process. π§
dsync can sync either one or multiple users using the -u or -A parameters. π
π GLOBAL OPTIONS π
Global doveadm(1) options:
-Dβ Enables verbosity and debug messages. π-Oβ Do not read any config file, just use defaults. Thedovecot_storage_versionsetting defaults to the latest version, but can be overridden with-o. β¨-kβ Preserve entire environment for doveadm, not justimport_environmentsetting. π-vβ Enables verbosity, including progress counter. π-iinstance-nameβ If using multiple Dovecot instances, choose the config file based on this instance name.
See instance_name setting for more information. π
-cconfig-fileβ Read configuration from the givenconfig-file. By default it first reads config socket, and then falls back to/etc/dovecot/dovecot.conf. You can also point this to config socket of some instance running compatible version. π§-osetting=valueβ Overrides the configuration setting from/etc/dovecot/dovecot.confand from the userdb with the given value. In order to override multiple settings, the-ooption may be specified multiple times. π
β¨ OPTIONS β¨
okay bestie this is the good part, the actual flags, let's go π
-Aβ if you pass-A, the command runs for all the users. lowkey a warning though: using this together with system users fromuserdb { driver = passwd }is not recommended, because that setup also contains users with a lower UID than the one you configured in thefirst_valid_uidsetting. π
When the SQL userdb module is in play, make sure the userdb_sql_iterate_query setting matches your database layout, fr fr.
And when you're on the LDAP userdb module, double check that the userdb_fields setting and the userdb_ldap_iterate_fields setting match your LDAP schema. Otherwise doveadm(1) literally cannot iterate over all users. no cap.
-Ffile β run the command for all the users listed in file. This is giving-Aenergy, but instead of pulling the user list from the userdb, it reads them from the file you gave it. The file has one username per line. π-1β do a one-way synchronization instead of a two-way one.-fβ do a full synchronization.-Nβ synchronize all the available namespaces. By default only theinbox=yesnamespace gets synced, which is giving "bare minimum" energy ngl.--no-userdb-lookupβ don't do the userdb lookup at all. Use theUSERenvironment variable to specify the username instead.-Pβ run adoveadm-purge(1)for the destination (remote) storage after synchronization. clean girl behavior β¨-Rβ do a reverse sync. Normally messages get pushed from the local system to the destination (remote). This flips the whole flow and pulls messages from the remote into the local storage instead. π-Ssocket_path β the argument here is either an absolute path to a local UNIX domain socket, or a hostname and port (hostname:port), so you can connect to a remote host via a TCP socket.
This lets an administrator execute doveadm(1) mail commands through that given socket.
-Tsecs β tell me how many secondsdoveadm(1)should wait for stalled I/O operations. The default timeout is 600 seconds.-psetting=value β overrides the configuration setting for the source storage.-gmailbox_guid β same as-m, but you find the mailbox to be synchronized by its GUID instead of by name.-lsecs β lock the dsync for this user, and wait for a maximum of secs before giving up. Use this to dodge a broken synchronization when it's possible that dsync is being run concurrently for the same user. π-mmailbox β synchronize only this mailbox name.-nnamespace β synchronize only the specified namespace. This parameter can be used multiple times.-aall mailbox β name for the "All mails" virtual mailbox. If you specify it, mails are attempted to be copied from this mailbox instead of being saved separately. This may reduce the total disk space usage as well as disk IO. slay πΎ-tstart date β skip any mails whose received-timestamp is older than the specified time.-eend date β skip any mails whose received-timestamp is newer than the specified time.-Osync flag β sync only mails that have the specified flag. If the flag name begins with"-", sync all mails except the ones with the specified flag.-Imax size β skip any mails larger than the specified size.-rrawlog_path β when running dsync remotely, write the remote input/output traffic to the specified log file.-sprevious_state β use stateful synchronization. This allows optimized incremental synchronization by providing a "sync state string" from the previous dsync run. dsync will use this state to only synchronize the changes that have occurred since that state was captured, avoiding a full mailbox scan. If the previous state is unknown, use an empty string. The new state is always printed to standard output if this parameter is specified. obsessed with how efficient this is π-uuser/mask β run the command only for the given user. You can also use'*'and'?'wildcards (e.g.-u *@example.org).-xmailbox_mask β exclude the specified mailbox name/mask. The mask may contain"?"and"*****"wildcards. The mask can also be a special-use name (e.g.\Trash). This parameter can be used multiple times.
π ARGUMENTS π
destinationβ this argument specifies the synchronized destination.
It can be one of:
mail_driver:mail_pathβ Uses the storage specified bymail_driverandmail_path. Use the-pparameter to specify additional settings.remote: login@hostβ Usesdsync_remote_cmdsetting to connect to the remote host (usually via ssh)remoteprefix:login@hostβ This is the same as remote, except"user@domain\n"is sent before dsync protocol starts. This allows implementing a trusted wrapper script that runsdoveadm dsync-serverby reading the username from the first line.tcp: host[:port]β Connects to remote doveadm server via TCP. The default port is specified bydoveadm_portsetting.tcps: host[:port]β This is the same as tcp, but with SSL.command [arg1 [, arg2, ...]]β Runs a local command that connects its standard input & output to a dsync server.
π EXIT STATUS π
dsync will exit with one of the following values:
0β Synchronization was done perfectly. periodt. β¨2β Synchronization was done without errors, but some changes couldn't be done, so the mailboxes aren't perfectly synchronized. Running dsync again usually fixes this. Typically this occurs for message modification sequences with newly created mailboxes. It can also occur if one of the mailboxes change during the syncing.1,>2β Synchronization failed. π
See also doveadm(1) for other possible error codes.
π EXAMPLE π
SYNCHRONIZATION
Synchronize mailboxes with a remote server. Any errors are written to stderr:
doveadm sync -u username@example.com remote:server-replica.example.com
If you need more complex parameters to ssh, you can use e.g.:
doveadm sync -u username@example.com ssh -i id_dsa.dovecot \
mailuser@example.com doveadm dsync-server -u username@example.com
CONVERTING
Example to convert mails from Maildir format to the format specified in the configuration file:
doveadm backup -u user maildir:~/Maildir
If you want to do this without any downtime, you can do the conversion one user at a time. Initially:
- Configuration uses
mail_driver = maildirandmail_path = ~/Maildir - Set up the possibility of doing per-user mail location using userdb extra fields.
Then for each user:
- Run
doveadm synconce to do the initial conversion. - Run
doveadm syncagain, because the initial conversion could have taken a while and new changes could have occurred during it. This second time only applies changes, so it should be fast. πββοΈ - Update userdb to return the wanted new mail format configuration. For example:
mail_driver = mdboxandmail_path = ~/mdbox. If you're using auth cache, you need to flush it, e.g.doveadm auth cache flush. - Wait for a few seconds and then kill (
doveadm kick) the user's all existing imap and pop3 sessions (that are still using maildir). - Run
doveadm synconce more to apply final changes that were possibly done. After this there should be no changes to Maildir, because the user's mail location has been changed and all existing processes using it have been killed.
Once all users have been converted, you can update the global mail_driver and mail_path settings and remove the per-user mail locations from userdb. π
π SECURITY π
bestie. listen. This command cannot be used safely by untrusted users, unless the input is heavily sanitized. The destination allows running arbitrary commands. If usingdsync_remote_cmd, the username and hostname may contain spaces or begin with a dash, which can allow passing unsafe parameters to ssh. Also since ssh runs commands via shell, parameters containing e.g.;or&&can result in running multiple commands. π be careful, i'm so serious.
π REPORTING BUGS π
Report bugs, including doveconf -n output, to the Dovecot Mailing List β¨dovecot@dovecot.orgβ©. Information about reporting bugs is available at: β¨https://dovecot.org/bugreport.htmlβ©
π SEE ALSO π
and that's the whole page bestie, you ate it up π this one's from the f979264 build, dated April 2026, and it's the DOVEADM-SYNC(1) manual β go forth and sync responsibly, mwah π«Άβ¨
π¦ where this page comes from
- alpine 3.23: dovecot-doc 2.4.5-r0 Β· MIT AND LGPL-2.1-or-later
- alpine 3.24: dovecot-doc 2.4.5-r0 Β· MIT AND LGPL-2.1-or-later
- arch rolling: dovecot 2.4.5-1 Β· MIT AND LGPL-2.1-only
- fedora 43: dovecot 1:2.4.5-1.fc43 Β· MIT AND LGPL-2.1-only
- fedora 44: dovecot 1:2.4.5-1.fc44 Β· MIT AND LGPL-2.1-only
- nixos 26.05: dovecot 2.4.5
- nixpkgs unstable: dovecot 2.4.5
- opensuse-leap 16.0: dovecot24 2.4.5-160000.1.1 Β· BSD-3-Clause AND LGPL-2.1-or-later AND MIT
- opensuse-leap 16.0: dovecot24 2.4.5-160000.1.1 Β· BSD-3-Clause AND LGPL-2.1-or-later AND MIT
- opensuse-leap 16.0: dovecot24 2.4.5-160000.1.1 Β· BSD-3-Clause AND LGPL-2.1-or-later AND MIT
- opensuse-leap 16.0: dovecot24 2.4.5-160000.1.1 Β· BSD-3-Clause AND LGPL-2.1-or-later AND MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms