My email provider is awesome, but the default mailbox size is 2G. In fact, this is a good thing because it forces me to clean up my mails from time to time. Today is such a day. But since I do not want to lose my old mail archives I wanted to create a backup of my full IMAP account first. Here’s what I did.
offlineimap is the perfect tool for the job. It’s designed to download an IMAP account to local Maildir (or other format) folders. Synchronising my account was as simple as installing it and creating a minimalist configuration. I am running Debian stable (buster), so the commands required may vary for you.
sudo apt install offlineimap
cp /usr/share/doc/offlineimap/examples/offlineimap.conf.minimal ~/.offlineimaprc
# edit config (see below) and then run:
# enter password when asked, then wait until it's done
As usual, the Arch Wiki has some great documentation. Here’s my configuration:
accounts = posteo
localrepository = Local
remoterepository = Remote
type = Maildir
localfolders = ~/backups/mails-202107
type = IMAP
remotehost = posteo.de
remoteuser = <my email address>
That’s it. Atferwards I could securely delete all the remote stuff I did not need anymore.
If I want to read mails from the backup, I can simply open them up in mutt:
mutt -R -f INBOX