The command imapsync is a tool allowing incremental and
recursive imap transfer from one mailbox to another.
By default all folders are transferred, recursively.
We sometimes need to transfer mailboxes from one imap server to
another. This is called migration.
imapsync is a good tool because it reduces the amount
of data transferred by not transferring a given message if it
is already on both sides. Same headers
and the transfer is done only once. All flags are
preserved, unread will stay unread, read will stay read,
deleted will stay deleted. You can stop the transfer at any
time and restart it later, imapsync works well with bad
You can decide to delete the messages from the source mailbox
after a successful transfer (it is a good feature when migrating).
In that case, use the --delete option. Option --delete implies
also option --expunge so all messages marked deleted on host1
will be really deleted.
(you can use --noexpunge to avoid this but I don't see any
real world scenario for the combinaison --delete --noexpunge).
You can also just synchronize a mailbox A from another mailbox B
in case you just want to keep a "live" copy of B in A (--delete2
imapsync is not adequate for maintaining two active imap accounts
in synchronization where the user plays independently on both sides.
Use offlineimap (written by John Goerzen) or mbsync (written by
Michael R. Elkins) for 2 ways synchronizations.