How can I back up a complete IMAP account?
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.