$Id: FAQ.Two_Ways_Sync.txt,v 1.9 2024/09/10 10:31:55 gilles Exp gilles $

This documentation is also available online at
https://imapsync.lamiral.info/FAQ.d/
https://imapsync.lamiral.info/FAQ.d/FAQ.Two_Ways_Sync.txt


=======================================================================
================  Two-way sync with Imapsync =========================
=======================================================================

=======================================================================
Q. Can Imapsync do a good "two ways" sync? 
   Short answer: no, not a good one. Why?

R. Imapsync can't do good two-way syncs.

A good "two ways" sync is impossible with imapsync because imapsync is
stateless.

Each time imapsync runs, it considers messages and folders as if it
were the first time it encounters them. Imapsync looks at messages,
flags, and folders as they are now, not considering what they were
before the current synchronization. Imapsync has no memory outside the
current running synchronization.

So now, why a stateless behavior cannot handle well a two-way sync
between account A and account B?

The problem arises with deletions, messages deletions, folder
deletions, or with moves like messages displacements across folders,
folder displacements, and folder renaming. Deletions and moves are
ambiguous changes when combined with creations on the opposite side.
 
For example, if a message is deleted from A by a user, then imapsync
cannot know whether it is a message deleted from A that has to be
deleted in B (what the user did) or a missing message in A that has to
be copied from B.

But if you know the answer yourself, that missing messages on one side
A are deleted messages that have to be deleted on the other side then
run a sync with the --delete2 option from A to B. This assumes there
are no new messages on B because --delete2 will delete them.

If you know that the missing messages on A are messages from B
that has to be copied to A, then run a sync from B to A.

If you know it's a mixed scenario, that there are some deletions/moves
on A, and there are some deletions/moves on B, but not the same, then
you are in trouble and it ends up with a not very good "two ways"
sync.  In that case, two runs of imapsync, one from A to B, and one
from B to A, put the two accounts in a synchronized state. The
deletions of messages on either side get canceled, and deleted
messages come back. A folder renaming on either side brings back the
old folder.  It's not a good two-way synchronization.


My suggestion is:

a) Use a single active imap account that fits all your needs,
   available from anywhere, at any time.  Access it from both your
   laptop and your iPhone.

b) Feed this active account with foreign and passive accounts with any
   tool that can handle the transfer, imapsync being one of them.

c) Have a slave imap backup account of the active one, available from
   anywhere at any time. Use it only as a failsafe account, when the
   active one is broken or to bring back misguidedly deleted messages
   to the active account. Use any tool that can handle the
   synchronization, imapsync being a good one.


=======================================================================
Q. What can I do instead of having two ways synchronizations?

R. My suggestion is:

a) Use only one single active imap account that fits all your needs,
   available from anywhere, at any time.  Access it from all your
   devices, laptops, phones, and tablets.

b) Feed this active account with foreign and passive accounts with any
   tool that can handle the transfer, imapsync being one.

c) Have a slave imap backup account of the active one, available from
   anywhere, at any time. Use it only as a failsafe account, when the
   active one is broken or to bring back misguidedly deleted messages
   to the active account. Use any tool that can handle the
   synchronization, imapsync being a good one of them.


=======================================================================
Q. What tools can I use to handle two-way synchronizations?

R. There are offlineimap and mbsync/isync tools:

offlineimap  is located at http://www.offlineimap.org/
mbsync/isync is located at https://isync.sourceforge.io/


=======================================================================
=======================================================================
