Backing up your email

From time to time it might be a good idea to make a full backup of your email.

I’m using Fastmail and this is what worked for me:

Create a read-only application password on Fastmail settings page.

brew install isync

Create a ~/.mbsyncrc file like this:

# First section: remote IMAP account
IMAPAccount fastmail
Host imap.fastmail.com
Port 993
User [your fastmail login]
AuthMechs PLAIN
TLSType IMAPS
Pass [the application password you created]
PipeLineDepth 1

IMAPStore fastmail-remote
Account fastmail

# This section describes the local storage
MaildirStore fastmail-local
Path ~/mail-backup/
Inbox ~/mail-backup/INBOX
SubFolders Verbatim

# This section a "channel", a connection between remote and local
Channel fastmail
Far :fastmail-remote:
Near :fastmail-local:
Patterns *
Expunge None
CopyArrivalDate yes
Sync All
Create Near
SyncState *

And then run

mbsync -a