How can I back up a complete IMAP account?

Solution 1:

You can do it with offlineimap. I'm using it for my GMail and Fastmail accounts.

Install Homebrew (you must also install Xcode). With Homebrew, brew install offline-imap.

Create ~/.offlineimaprc config file:

[general]
ui = ttyui
accounts = fastmail
maxsyncaccounts = 4
socktimeout = 60

[Account fastmail]
localrepository = fastmail-local
remoterepository = fastmail-remote

[Repository fastmail-local]
type = Maildir
localfolders = ~/Mail/Fastmail

[Repository fastmail-remote]
type = IMAP
remotehost = mail.messagingengine.com
remoteuser = username
remotepass = password

expunge = no
folderfilter = lambda foldername: foldername not in ['INBOX.Trash']

A big advantage of offlineimap is that it creates the folders you have on your IMAP server.

I'm reading my backup with mutt.

Solution 2:

In the lefthand sidebox you can just drag mailboxes from the imap location to the On My Mac location.

Otherwise See Mail's help for Archiving mailboxes

Archive the mailbox which puts it on your computer then import the mailbox

I am not certain if the directories are kept,