Skip to main content

OfflineIMAP

·1 min

Here’s how I setup OfflineIMAP to take regular backups of our Gmail accounts:

# Install, on Raspberry Pi.
sudo apt install offlineimap3

cat > ~/.offlineimaprc << 'EOF'
[general]
accounts = foo1, foo2

[Account foo1]
localrepository = foo1-local
remoterepository = foo1-remote
synclabels = yes
# This header is where labels go.  Usually you will be fine
# with default value (X-Keywords), but in case you want it
# different, here we go:
labelsheader = X-Keywords

[Repository foo1-remote]
type = Gmail
sslcacertfile = OS-DEFAULT
remoteuser = [email protected]
remotepass = pass1
readonly = True

[Repository foo1-local]
type = GmailMaildir
localfolders = /srv/dev-disk-by-uuid-28fd4901-c675-430d-be16-e1ffddc50727/Backups/Emails/[email protected]

[Account foo2]
localrepository = foo2-local
remoterepository = foo2-remote
synclabels = yes
# This header is where labels go.  Usually you will be fine
# with default value (X-Keywords), but in case you want it
# different, here we go:
labelsheader = X-Keywords

[Repository foo2-remote]
type = Gmail
sslcacertfile = OS-DEFAULT
remoteuser = [email protected]
remotepass = pass2
readonly = True

[Repository foo2-local]
type = GmailMaildir
localfolders = /srv/dev-disk-by-uuid-28fd4901-c675-430d-be16-e1ffddc50727/Backups/Emails/[email protected]
EOF

Other resources: