Offlineimap erroneously deletes 10,000 emails

seanh snhmnd at
Thu May 19 13:36:46 BST 2011

Hey, so I was running offlineimap (version 6.2.0 on OS X,from macports)
recently and I saw this:

Deleting 9810 messages (...) in Maildir [Archive], LocalStatus[Archive]

where the (...) was the identifiers of 9810 messages, i.e. the entire
contents of my Archive folder containing several years worth of archived
personal emails. Fortunately I killed offlineimap after it had managed
to delete only a couple of thousand emails, and before it had synced
this change up to the IMAP server and deleted the emails from the server
as well (which would have lost them completely).

This is not the first time that offlineimap has done this to me, it's
just the first time that I've caught it in the act. A few times over the
years, when using offlineimap I've noticed dozens or hundreds of emails
have mysteriously gone missing from my maildirs and from the IMAP

Offlineimap apparently believed that all of the messages in the Archive
folder had been deleted from the IMAP server so it was syncing this
change to the local mailbox. But the messages had not been deleted from
the server, and I confirmed this (after killing the offlineimap process)
by connecting to the IMAP server using mutt and opening the Archive
folder, which still contains 9810 messages.

If I hadn't happened to have been looking at the offlineimap window when
this happened (or if, say, offlineimap was being run by cron) then it
would have deleted the 9810 messages from the local maildir and then on
the next automatic sync a few minutes later it would have sent the same
change back up to the IMAP server and deleted the messages from the
server, losing them forever.

Is this a bug in the offlineimap code? Or a bug in offlineimap's sync
algorithm? Was there a glitch in the IMAP server that caused it to
momentarily report the contents of the Archive folder as empty and
trigger a catastrophic response from offlineimap? Is there a safe way to
use offlineimap so that I can be protected from losing mail in events
like this?

Reading local maildirs with mutt is my preferred way to check my mail
and offlineimap is the best/the only way to sync my IMAP accounts
locally. But having seen this, I may have to give offlineimap up. I
can't trust it not to wipe out all my email in one sudden, unexpected

More information about the OfflineIMAP-project mailing list