Can offlineimap do a one-way sync?

The current behavior you describe is called "one-way sync" – all changes in one side, including deletion, are propagated to the other side.

For a permanent cache, look into getmail or fetchmail.

# ~/.getmail/getmailrc
[retriever]
  type = SimpleIMAPSSLRetriever
  server = imap.gmail.com
  username = ...
  password = ...
[destination]
  type = Maildir
  path = ~/backup/gmail

Both these programs support fetching from IMAP and POP3 mailboxes, but IMAP is usually preferred.


OfflineIMAP does support one-way sync (no updates to the actual mail server's mailbox), using the readonly = True option. See the sample configuration file in the official GitHub repository.

So your .offlineimap config file should contain:

[Repository Gmailserver-foo]
#This is the remote repository
type = Gmail
remotepass = XXX
remoteuser = XXX
readonly = true

this is my configuration file used to do one-way-sync from one gmail account to another

[general]
accounts = GmailMigration
socktimeout = 600
maxsize = 25000000

[Account GmailMigration]
localrepository = sourceAccount
remoterepository = dstAccount

[Repository sourceAccount]
type = IMAP
remotehost = imap.gmail.com
remoteport = 993
remoteuser = ...
remotepass = ...
ssl = yes
sslcacertfile = /etc/ssl/certs/ca-certificates.crt
readonly = true

[Repository dstAccount]
type = IMAP
remotehost = imap.gmail.com
remoteport = 993
remoteuser = ...
remotepass = ...
ssl = yes
sslcacertfile = /etc/ssl/certs/ca-certificates.crt

Basically you want is an archive of mails. One way you can achieve it is you can automatically forward mails from your current mail account to another mail account. Most of all free mail services provide this facility. Then you setup offlineimap to sync this second mailbox locally. And never delete any mail from this second mailbox. Use this mailbox for only archiving.