Here’s a thing almost nobody does until it’s too late: backing up email. Your inbox lives on someone else’s server, behind a login, and you assume it’ll be there forever. Then an account gets locked, a provider shuts down a service, a laptop dies mid-migration, or you fat-finger a delete on a folder you actually needed. Email is your business correspondence, your receipts, your contracts and your password-reset safety net — and for a lot of people it exists in exactly one place.
The good news is that the free and open source world has this covered, and it has for years. The bad news is that „back up my email“ means at least three different things depending on what you actually want, and the tools split neatly along those lines: command-line engines that pull IMAP into a local Maildir, self-hosted archiving platforms with search and retention policies, and plain desktop apps you click through. This guide covers all three, plus the one step most people skip — actually making the local copy a real backup.
It’s the companion to my IMAP filtering guide: that one is about sorting your mail, this one is about making sure you never lose it.
The short version: use mbsync (isync) or imap-backup to pull your mailbox into a local Maildir on any platform. Reach for Open Archiver or piler if you want a real self-hosted archive with full-text search and retention policies in Docker. If you’d rather click than type, Thunderbird with ImportExportTools NG exports any folder to mbox on Mac, Linux and Windows for free. And whatever you pick, point restic or kopia at the result so a single bad disk doesn’t undo the whole exercise.
Why Bother Backing Up IMAP Email?
- Your provider is not a backup — a hosted mailbox is one copy, on one account, controlled by someone else. One compromised login or one accidental „delete all“ and it’s gone
- Providers disappear and terms change — free tiers get retired, accounts get locked, and companies get acquired. A local copy is the only thing that survives a shutdown
- Migration is painful without one — moving between providers is a hundred times easier when you already have every message in a portable format (Maildir or mbox), not trapped behind an IMAP connection
- Ransomware and accidents are real — a synced client happily mirrors a deletion. An append-only, versioned backup doesn’t
- Some of us have to keep it — German businesses are legally required to retain business correspondence and tax-relevant documents for years (more on the GoBD below)
- Search and history — a local archive you control is searchable, offline, and independent of whatever the provider’s web UI decides to show you today
What „Backup“ Actually Means — Three Different Jobs
Before picking a tool, decide which of these you actually need, because they’re not interchangeable and the best answer for you depends entirely on this:
- Extraction (IMAP → local files) — tools like mbsync and imap-backup mirror your mailbox down to Maildir or EML files. This is what most people mean by „email backup“: a portable, provider-independent copy you can search and restore from
- Archiving (a system of record) — platforms like Open Archiver and piler capture mail continuously (often via journaling or scheduled sync), index it for full-text search, and apply retention and legal-hold rules. This is what you want for compliance, eDiscovery and audit trails
- Desktop export (GUI) — Thunderbird, Evolution and MailStore Home let you export or archive mail from a client you already use. Lowest effort, least automation
And then there’s the step everybody forgets: a local copy is not a backup until it lives somewhere else too. Keep it simple — pair your extractor with restic, kopia, Borg or Duplicati and you get versioning, encryption and off-site copies for free.
Find Your Email Backup Tool in 30 Seconds
Every option links to its official page, and every row links to the full write-up below.
The Classic CLI Engines
These are the workhorses: small, scriptable, battle-tested programs that pull IMAP into local files you own. They’re not glamorous, but they’re the backbone of every serious self-hosted mail setup, and several of them are older than some of the companies whose mail they archive.
mbsync (isync) — The Fast, Reliable Standard
mbsync is the binary of the isync project, a C program that synchronizes IMAP and Maildir mailboxes both ways and is built to survive interruption — which is exactly what you want in something that runs on a schedule over a flaky connection. It’s the tool most self-hosters reach for first, and it handles the awkward parts (UID validity, TLS, OAuth2) properly.
- License: GPL-2.0 | Latest: 1.5.1 (2025) | Language: C — a near-zero-dependency binary
- Platforms: Linux, macOS (Homebrew) and Windows via WSL; Docker images exist (see below)
- One-way or two-way sync, fine-grained control over what propagates (new mail, deletions, flags)
- Perfect for: the everyday „mirror my mailbox to a local Maildir“ job on any OS
- The catch: it’s a config-file tool with a slightly terse syntax, and it needs a wrapper (cron, systemd timer or Docker) to run on a schedule
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# ~/.mbsyncrc IMAPAccount myaccount Host imap.example.com User me@example.com PassCmd "pass show mail/example" IMAPStore myaccount-remote Account myaccount MaildirStore myaccount-local Path ~/Mail/example/ Inbox ~/Mail/example/INBOX SubFolders Verbatim Channel myaccount Far :myaccount-remote: Near :myaccount-local: Patterns * Create Both Expunge Both # then run it (e.g. from cron or a systemd timer) mbsync -a |
Docker: theohbrothers/docker-isync is the maintained image — it mounts /mbsyncrc and /mail and runs /sync, with notification helpers baked in.
|
1 2 3 4 5 6 7 |
services: isync: image: theohbrothers/docker-isync:latest restart: unless-stopped volumes: - ./mbsyncrc:/mbsyncrc:ro - ./mail:/mail |
imap-backup — Purpose-Built, Cross-Platform
imap-backup is the tool that does one job and says so in the name: it backs up and migrates IMAP accounts to your disk as plain EML files plus a JSON index, folder structure intact. It’s written in Ruby, runs the same on Mac, Linux and Windows, and handles incremental runs so the second backup is fast.
- License: MIT | Language: Ruby (installed as a gem) | Platforms: macOS, Linux, Windows
- Incremental backups, multi-account config, and a
migratecommand to push a backup into a new server - Gmail and Microsoft 365 via OAuth2 through email-oauth2-proxy (the awkward auth bit, handled separately)
- Perfect for: a simple, portable „get everything down as files“ backup on any desktop OS
- The catch: Ruby runtime required; no official daemon, so you’ll schedule it yourself
|
1 2 3 4 5 6 7 8 9 10 |
gem install imap-backup # interactive setup: server, user, password, path imap-backup setup # back up every configured account imap-backup # later: restore into a new server imap-backup migrate me@example.com --destination new@example.com |
mailvault — One Plain .eml File Per Message
mailvault is a Python toolkit that takes a deliberately old-fashioned approach: it writes one RFC 822 .eml file per message into a directory you can walk with ls, each named after the hash of its own content. There’s no container format to unpack and no database you need in order to read your own mail — which is exactly the point. It talks plain IMAP, Gmail, Microsoft 365 over MS Graph and Proton Mail via the Bridge, and it can optionally build a throwaway SQLite index for searching.
- License: GPL-3.0 | Language: Python 3 (install with uv/pipx, or grab a standalone
.exe) | Platforms: macOS, Linux, Windows - Incremental: after the first run it only fetches new mail;
delete_after_exportarchives then trims the server, only after the message is durably stored - Built-in
verify --repair, an optional query database (db create/db search), and an MCP server to expose the archive to AI clients - Perfect for: a durable, tool-independent archive that will still be readable in ten years, and for clearing out a mailbox that’s filling up
- The catch: a young project, and one file per message means a lot of files — great for durability, less fun for casual browsing
|
1 2 3 4 5 6 7 8 9 10 |
uv tool install mailvault mailvault archive init /srv/archive/private # creates the archive + mailvault.toml # edit mailvault.toml, then: mailvault backup # nightly via cron; only new mail after run 1 mailvault verify --repair # check the archive against the mailbox # optional: build a searchable index mailvault db create mailvault db search --from example.com --since 2024-01-01 |
getmail6 — The Flexible Retriever
getmail6 is the community-maintained Python 3 fork of Charles Cazabon’s classic getmail. It retrieves mail over POP3 or IMAP (encrypted or not) and delivers it to Maildir, mbox or an external MDA, with message filtering along the way. It’s the Swiss Army knife of mail retrieval, and it’s actively maintained again.
- License: GPL-2.0 | Latest: 6.20.0 (2026) | Language: Python 3 | Platforms: macOS, Linux, Windows
- POP3 and IMAP, SSL variants, maildir/mbox/MDA delivery, domain mailboxes
- Reliable „leave a copy on the server“ semantics for archive-then-trim workflows
- Perfect for: scheduled pulls where you want fine control over delivery and filtering
- The catch: oldest-school of the bunch — one config file per account, run from cron
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# ~/.getmail/getmailrc [retriever] type = SimpleIMAPSSLRetriever server = imap.example.com username = me@example.com password = secret [destination] type = Maildir path = ~/Mail/example/ [options] read_all = false delete = false # keep a copy on the server # run it getmail --getmaildir ~/.getmail |
offlineimap3 — The Classic, Revived
offlineimap3 is the Python 3 continuation of the long-running OfflineIMAP, and it’s alive again — commits through 2026, a clean community fork, and the same two-way Maildir synchronization people have relied on for over a decade. It supports multiple accounts, IMAP IDLE, and its own status tracking, and there’s a GUI (offlineimap) if you want one.
- License: GPL-2.0 | Language: Python 3 | Platforms: Linux, macOS, Windows
- Two-way sync, multiple accounts, IMAP IDLE, configurable folders and filters
- Large installed base and a lot of tribal knowledge in forums and wikis
- Perfect for: people who already have an offlineimap config, or want IDLE-based near-real-time sync
- The catch: historically slower than mbsync on big mailboxes, and the original project’s turbulent history means you should make sure you’re on the maintained fork
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# ~/.offlineimaprc [general] accounts = myaccount ui = ttyui [Account myaccount] localrepository = local remoterepository = remote [Repository local] type = Maildir localfolders = ~/Mail/example [Repository remote] type = IMAP remotehost = imap.example.com remoteuser = me@example.com remotepass = secret ssl = yes |
fetchmail — The Original
fetchmail has been pulling mail since the mid-1990s and is still maintained (6.6.4 shipped in May 2026). It retrieves from POP3, IMAP, ETRN and ODMR and forwards to your local MTA or MDA. For a pure „download everything and hand it to a local delivery agent“ workflow it’s rock solid.
- License: GPL-2.0 | Latest: 6.6.4 (2026) | Language: C | Platforms: Linux, macOS, BSD and other Unix
- Retrieval and forwarding, keep/mailbox/flush modes, runs as a daemon or from cron
- Perfect for: veteran Unix setups that deliver into a local MTA/MDA pipeline
- The catch: it’s a retriever, not a two-way sync — it forwards mail and doesn’t manage a mirror the way mbsync does; Windows support is not the point
|
1 2 3 4 5 6 7 8 |
# ~/.fetchmailrc poll imap.example.com with proto IMAP user "me@example.com" there with password "secret" is "me" here keep ssl # fetch quietly and forward to the local MDA fetchmail -s |
imapsync — Server-to-Server Migration and Backup
imapsync is the giant of IMAP transfers: Perl, actively released (2.229 in 2026), and explicitly designed to „migrate IMAP accounts or to backup IMAP accounts.“ Unlike the pull-to-disk tools, it copies directly from one IMAP server to another, which makes it the standard choice for provider migrations — and for mirroring an account to a second mailbox as an off-site backup.
- License: freely downloadable source (Artistic-style); the author sells support and commercial licenses | Latest: 2.229 | Language: Perl | Platforms: macOS, Linux, Windows, Docker
- Server-to-server sync with huge real-world mileage and a long list of provider-specific fixes
- Perfect for: migrating between providers, or syncing a live mailbox to a second account
- The catch: it’s not a local-file backup — you need a destination server; and commercial use nudges you toward the paid license/support
|
1 2 3 4 5 6 7 8 |
services: imapsync: image: gilleslamiral/imapsync:latest restart: "no" command: > --host1 imap.old.example --user1 me@old.example --password1 secret --host2 imap.new.example --user2 me@new.example --password2 secret --useuid --delete2 |
Dovecot doveadm backup / dsync — For Self-Hosted Servers
If you already run Dovecot, you have a first-class backup tool built in. doveadm backup (and its two-way sibling doveadm sync) replicate a mailbox with protocol-level fidelity, including flags and keywords, and they can talk to any IMAP server via Dovecot’s imapc driver.
- License: LGPL-2.1 / MIT (Dovecot) | Language: C | Platforms: Linux and other Unix (Dovecot)
- Runs natively against Dovecot dbox/Maildir or against a remote server via
imapc - Perfect for: self-hosted mail servers where you control Dovecot — the most efficient option if the backup target is also Dovecot
- The catch: it’s part of a mail server, so it’s not a drop-in for a hosted Gmail/Fastmail account unless you set up Dovecot to proxy one
|
1 2 3 4 5 6 7 8 |
# one-way: make the destination look exactly like the source doveadm backup -u me@example.com imapc: # safer for a live mailbox: sync only what's new doveadm sync -1 -u me@example.com imapc: # push a local Maildir backup into Dovecot doveadm backup -u me@example.com maildir:~/Mail/example |
Local Archive and Search
Between „a pile of EML files“ and „a server with a web UI“ sits a newer category: a local-first archive that wants to be searched. It’s the answer when you want your whole history on your own machine, queryable, without standing up a service.
msgvault — Archive a Lifetime, Then Query It
msgvault, started by Wes McKinney (of pandas fame), is a local-first archive for email, chat, calendars and contacts, stored in SQLite and DuckDB/Parquet so you can run millisecond queries over decades of history. It syncs Gmail and IMAP, imports mbox and Apple Mail exports, and gives you a browser app, a terminal UI, a CLI, an HTTP API and an MCP server — all entirely offline once synced.
- License: MIT | Language: Go | Platforms: macOS, Linux, Windows (installer script, Homebrew, conda-forge or release binaries)
- Full-text search, analytics, optional local/remote AI features, and identity/contact linking
- Perfect for: power users who want one queryable archive of a lifetime of communication on their own hardware
- The catch: it’s alpha software — the storage format and CLI can change without notice — and it’s a bigger, more opinionated thing than a straight backup
|
1 2 3 4 5 6 7 8 |
# macOS/Linux installer (Homebrew: brew install msgvault) curl -fsSL https://msgvault.io/install.sh | bash msgvault init-db msgvault add-account you@gmail.com msgvault sync-full you@gmail.com --limit 100 msgvault serve # web UI + HTTP API msgvault tui # terminal UI |
The Self-Hosted Archiving Platforms
If you want more than files on a disk — search, retention rules, audit trails, a web UI — these are the platforms to run. They’re the right answer for teams, for regulators, and for anyone who wants an email archive rather than just a pile of EML.
Open Archiver — The Modern, Docker-First Archive
Open Archiver is the one most people should look at first in 2026. It’s a young (started mid-2025) but fast-moving TypeScript platform that ingests mail from Google Workspace, Microsoft 365, PST files and any generic IMAP mailbox, stores it, indexes it with Meilisearch, and gives you a web UI for full-text search and eDiscovery. It’s built Docker-first with a Compose stack.
- License: AGPL-3.0 (open source) with a paid Enterprise edition for journaling/retention extras | Platforms: Linux/Docker (the server side); you reach it from any browser
- Requirements: Docker + Compose, 4 GB RAM (2 GB with external Postgres, Valkey and Meilisearch); stores to a local volume or S3-compatible object storage
- Full-text search, RBAC, optional AES-256 encryption at rest, local or S3 storage
- Perfect for: self-hosters and small teams who want a searchable, sovereign email archive without a sales call
- The catch: it’s new — a big open-issue count and a fast-changing codebase. The compliance-grade retention and SMTP journaling features live in the Enterprise edition
|
1 2 3 4 5 |
git clone https://github.com/LogicLabs-OU/OpenArchiver.git cd OpenArchiver cp .env.example .env # set POSTGRES_PASSWORD, JWT_SECRET, ENCRYPTION_KEY, ... docker compose up -d # web UI on http://localhost:3000, first visit runs /setup |
|
1 2 3 4 5 6 7 8 |
# the shape of the shipped stack (abridged) services: open-archiver: image: logiclabshq/open-archiver:latest restart: always env_file: .env volumes: - archiver-data:/var/data/open-archiver |
piler — The Scalable, GoBD-Minded Veteran
piler is the old guard of open source email archiving, and it’s still actively developed (commits through 2026). It’s a PHP/C application that ingests mail via SMTP journaling (Postfix, Exchange, Google Workspace), deduplicates messages and attachments, indexes everything, and provides search, retention rules, access controls and an audit trail. It comes in a free Open Source Edition and a paid Enterprise Edition.
- License: GPLv3 (Community Edition) plus a commercial Enterprise Edition | Language: PHP/C | Platforms: Linux (self-hosted); Dockerized installs are community-supported
- Ingestion via journaling, message/attachment deduplication, full-text search, retention and legal hold
- The most explicit privacy/retention feature set of the three (see the GoBD section below)
- Perfect for: organizations that need a compliant, searchable archive rather than just a local copy
- The catch: heavier to install than a single Compose file, and you’re on Linux; the advanced compliance tooling is the paid edition
|
1 2 3 4 5 |
# Open Source Edition, built from source wget https://github.com/jsuto/piler/archive/refs/heads/master.tar.gz tar xzf master.tar.gz && cd piler-master ./configure && make && sudo make install # then configure journaling on your MTA so a copy of every mail lands in the archive |
MailArchiva — Open Core, Free for Small Setups
MailArchiva is a long-standing email archiving, eDiscovery and compliance platform built on Java, with both Windows and Linux server editions. It’s dual-licensed: a GPL Open Source Edition and a commercial Enterprise Edition, and the on-premises edition is free for organizations with nine or fewer mailboxes — which makes it a genuinely free option for a home lab or a very small shop.
- License: GPL (Open Source Edition) / commercial (Enterprise); free on-premises tier for up to 9 mailboxes | Language: Java | Platforms: Linux and Windows (server); browser UI
- Archiving, eDiscovery, compliance and forensics features with a web interface
- Community Docker images exist (see below) for running it in a container
- Perfect for: small businesses that want a real archiving product at zero cost, or Windows shops
- The catch: it’s open core, not fully open source — the good stuff is the paid edition, and above nine mailboxes the free tier ends
|
1 2 3 4 |
# install the server from the vendor (Linux or Windows), then reach the web UI: # https://mailarchiva.example.com:8090/ # a community Docker image is available if you prefer containers: # https://github.com/tgoetten/mailarchiva-dockerized |
bichon — Rust Archiving Server With a Web UI
bichon is a self-hosted email archiving server written in Rust. It downloads mail from multiple IMAP accounts (password or OAuth2), does incremental UID-based fetching, builds a full-text search index with Tantivy, deduplicates by content hash, and serves a REST API with an embedded web UI — all from a single binary with no external database.
- License: AGPL-3.0 | Language: Rust | Platforms: Linux, macOS and Windows binaries, plus an official Docker image
- Multi-account IMAP + OAuth2, RBAC with roles, import from EML/MBOX/Thunderbird/PST, optional embedded SMTP receiver, MBOX export
- Self-contained storage (Tantivy index + compressed blob store + embedded metadata DB) — nothing else to run
- Perfect for: a fast, searchable, self-hosted archive server that a small team can share
- The catch: young and moving fast (there’s a v0.x → v2 storage migration to watch), AGPL matters if you embed it, and it explicitly demands local storage — no NFS/SMB for its data.
|
1 2 3 4 5 6 7 8 9 10 11 12 |
services: bichon: image: rustmailer/bichon:latest restart: always ports: - "15630:15630" volumes: - ./bichon-data:/data environment: BICHON_ROOT_DIR: /data BICHON_ENCRYPT_PASSWORD: change-me # WebUI on http://localhost:15630 -- change the default admin password at once |
Mail-Archiver — .NET Archive With Retention Rules
Mail-Archiver is a self-hosted web application (.NET + PostgreSQL) for archiving, searching and exporting mail from multiple accounts. It handles plain IMAP, Microsoft 365 via Microsoft Graph, personal Microsoft accounts, and import-only accounts, and it adds the compliance-flavored bits: retention policies that delete from the server after a set period, a deletion lock that stops anyone removing archived mail, and a detailed access log.
- License: GPL-3.0 | Language: C#/.NET | Platforms: Docker (server); browser UI
- Requirements: Docker + Compose and a PostgreSQL database; put it behind a reverse proxy for HTTPS
- Multi-user with per-account permissions, OIDC login, read-only REST API and an MCP endpoint for AI agents, mbox/EML export, mailbox migration
- Perfect for: small teams that want archive + retention rules + an audit trail in one Docker stack
- The catch: it brings its own Postgres (more moving parts than piler or Open Archiver), and the documentation is still growing
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
services: mailarchive-app: image: s1t5/mailarchiver:latest restart: always environment: - ConnectionStrings__DefaultConnection=Host=postgres;Database=MailArchiver;Username=mailuser;Password=change-me - Authentication__Username=admin - Authentication__Password=change-me ports: - "5000:5000" depends_on: - postgres postgres: image: postgres:17-alpine restart: always environment: POSTGRES_DB: MailArchiver POSTGRES_USER: mailuser POSTGRES_PASSWORD: change-me volumes: - ./postgres-data:/var/lib/postgresql/data |
Free Desktop Apps (Mac, Linux, Windows)
Sometimes you just want to click a menu and export a folder. These are the free apps that do it, and between them they cover all three desktop platforms.
There are polished paid desktop apps too, if you’d rather pay than self-host: MailStore Server/Service Provider (the commercial big brother of MailStore Home), Mail Backup X, MailSteward and Aid4Mail for Mac and Windows, and the cross-platform MailVault app — a different product from the open-source mailvault above. None of them are open source, so they don’t get a full entry here, but for a non-technical user who just wants a big button, they exist.
Thunderbird + ImportExportTools NG — The Cross-Platform Freebie
Thunderbird already downloads your IMAP mail locally, and the ImportExportTools NG add-on turns that local cache into exports: pick any folder (or many) and save it as mbox, EML, HTML, PDF, CSV or plaintext, with or without attachments. It also exports and imports whole Thunderbird profiles and can auto-back-up on shutdown.
- License: MPL-2.0 (Thunderbird) / GPL-3.0 (add-on) | Add-on version: 15.0.3 (September 2026) | Platforms: macOS, Linux, Windows
- Export folders to mbox or individual EML files; bulk export; search-result export; CSV indexes
- Perfect for: a no-terminal, no-Docker backup of a specific mailbox on any desktop OS
- The catch: it’s manual or semi-manual, not a scheduled server-side backup; exporting an entire large mailbox can take a while and needs disk space
|
1 2 3 |
# In Thunderbird: right-click a folder # -> ImportExportTools NG -> Export all messages in this folder -> EML format # Or export the whole folder tree as one mbox file for a portable archive. |
Evolution — The Linux Built-In
Evolution is the GNOME mail client, and it ships a proper backup feature that packages your accounts, settings and local mail into a single archive you can restore later. If you’re on Linux and already use it, you have a one-click backup built in.
- License: GPL-2.0 | Platforms: Linux (GNOME)
File → Back up Evolution Dataproduces a.tar.gzof your mail and configuration- Perfect for: Linux users who want the simplest possible whole-client backup
- The catch: Linux-only, and it backs up the client’s local store rather than giving you a clean per-message archive
|
1 2 |
# GUI: File -> Back up Evolution Data... -> save the .tar.gz somewhere safe # Restore later with: File -> Restore Evolution Data... |
MailStore Home — Free but Windows-Only (and Closed Source)
MailStore Home is the free version of a commercial archiving product. It centralizes mail from multiple clients and mailboxes into one searchable archive, and for a single Windows user it’s polished and genuinely free. I’m including it as the honest „free app“ answer for Windows, with a clear caveat.
- License: freeware, closed source (not open source) | Platforms: Windows only
- Archives Outlook, Thunderbird, Exchange and generic IMAP/POP3 accounts into one local database
- Perfect for: Windows users who want a friendly, set-and-forget local archive
- The catch: it’s proprietary and Windows-only, and the free „Home“ edition is explicitly not for commercial use — businesses need the paid MailStore Server/Service Provider editions
|
1 2 3 4 |
# MailStore Home is a GUI app: # 1. Install, create an archive profile per account # 2. Run "Archive E-mail" (scheduled archiving is available) # 3. Search the archive from the same window |
Gmail-Specific: Got Your Back (GYB)
GYB — Back Up Gmail via the Official API
Got Your Back (GYB) is the Gmail-specific option from the GAM team. It uses Gmail’s own API over HTTPS to back up everything to local mbox files and — crucially — to restore messages back into a Gmail account, labels and all. For heavy Gmail users it’s more robust than IMAP scraping, and Google’s own Google Takeout remains the zero-setup manual alternative.
- License: Apache-2.0 | Language: Python | Platforms: macOS, Linux, Windows
- Full or incremental backup to mbox, plus restore into Gmail; handles large mailboxes across the API
- Perfect for: Gmail and Google Workspace accounts, especially if you might need to restore
- The catch: Gmail-only, and it needs Google API credentials set up once
|
1 2 3 4 5 |
git clone https://github.com/GAM-team/got-your-back cd got-your-back ./gyb --email me@example.com --action backup # later, restore into the same or another Gmail account: ./gyb --email me@example.com --action restore |
Turn It Into a Real Backup
A Maildir on one disk is still a single point of failure. The final step is to point a proper backup tool at the folder your extractor produces, so you get versioning, encryption, deduplication and an off-site copy. These four are all free, open source and cross-platform, and any of them will do.
restic — Fast, Encrypted, Single Binary
restic is the modern default: one Go binary, encrypted and deduplicated repositories, and support for local disks plus dozens of cloud backends. Point it at your Maildir and schedule it.
- License: BSD-2-Clause | Platforms: macOS, Linux, Windows, Docker
- Encrypted, deduplicated, snapshot-based;
restic forget --prunehandles retention - Perfect for: a simple, scriptable, off-site-capable backup of your local mail store
|
1 2 3 4 5 6 |
export RESTIC_REPOSITORY=/mnt/backup/mail export RESTIC_PASSWORD_FILE=/root/.restic-pass restic init restic backup ~/Mail restic forget --keep-daily 7 --keep-weekly 4 --prune |
kopia — Policy-Driven With a GUI
kopia is restic’s friendlier cousin: the same encrypted, deduplicating model, but with snapshot policies, a web UI and a tray app on Windows and macOS. Great when you want „set it and forget it“ without living in the terminal.
- License: Apache-2.0 | Platforms: macOS, Linux, Windows
- Policies, scheduling, a GUI and CLI, and many storage backends
- Perfect for: desktop users who want scheduled, versioned backups without cron
BorgBackup — The Deduplicating Classic
BorgBackup is the long-standing dedup-and-encrypt tool beloved by the self-hosting crowd. It’s extremely efficient on mail archives, where most messages never change, and its borgmatic wrapper makes scheduling and pruning easy.
- License: BSD-3-Clause | Platforms: Linux, macOS, Windows (via WSL)
- Heavy deduplication, compression, encryption, mount-any-snapshot for restores
- Perfect for: Linux servers backing up large, slowly-changing mail stores
Duplicati — GUI Backup With Cloud Targets
Duplicati is the point-and-click option: a web GUI that backs up folders to local disks and a long list of cloud services, with encryption and versioning built in. It’s the easiest way to get a Maildir off your machine if you’d rather not touch a config file.
- License: LGPL-2.1 | Platforms: macOS, Linux, Windows, Docker
- Browser UI, scheduling, encryption, many cloud backends
- Perfect for: non-terminal users who want an off-site copy with minimal fuss
If You’re in Germany: GoBD and Audit-Proof Archiving
If your business is subject to German tax law, „backup“ and „archive“ stop being the same thing, because the GoBD (Grundsätze zur ordnungsmäßigen Führung und Aufbewahrung von Büchern, Aufzeichnungen und Unterlagen in elektronischer Form sowie zum Datenzugriff) set binding rules for how tax-relevant records must be kept and made accessible. For email, that matters the moment a message contains an invoice, a contract, a payment confirmation or general commercial correspondence: it has to be retained for years — business correspondence generally six years, and accounting documents longer, with the 2025 Bürokratieentlastungsgesetz (BEG IV) cutting the retention period for most Buchungsbelege from ten years to eight — and it has to stay complete, unalterable and traceable for the whole period, with the tax office able to search and export it during an audit (the Z1/Z2/Z3 access levels). That’s a fundamentally different requirement from a synced Maildir copy, where you can quietly edit or delete a message. It’s why the self-hosted platforms above exist: a system like piler — which markets itself squarely at GoBD use cases — stores the original EML, hashes and audits access, supports WORM-style storage and dedicated auditor roles, while Open Archiver targets the same „legal archiving and eDiscovery“ niche. Two honest caveats: no tool makes you compliant on its own — you still have to write the mandatory Verfahrensdokumentation describing the system, the process and the access controls — and GoBD (retain everything tax-relevant) and GDPR (delete what you no longer need) pull in opposite directions, so you need clear retention rules and a legal basis for what you keep. If any of that applies to you, talk to your tax advisor before you delete anything, and treat the free/open-source archivers as the technical half of a bigger compliance job.
Email & IMAP Backup Tools Compared
Two tables, because „which platforms does it run on“ and „what does it actually do“ are different questions. Details are as of October 2026.
Platforms & maintenance
| Tool | License | macOS | Linux | Windows | Docker |
|---|---|---|---|---|---|
GPL-2.0 | Yes | Yes | WSL | Yes | |
MIT | Yes | Yes | Yes | Manual | |
GPL-3.0 | Yes | Yes | Yes (.exe) | Manual | |
GPL-2.0 | Yes | Yes | Yes | Manual | |
GPL-2.0 | Yes | Yes | Yes | Manual | |
GPL-2.0 | Yes | Yes | No | Manual | |
Free/commercial | Yes | Yes | Yes | Yes | |
LGPL/MIT | No | Yes | No | No | |
AGPL-3.0 | Server via Docker | Yes | Server via Docker | Yes | |
GPLv3 + paid EE | No | Yes | No | Community | |
GPL/commercial | No | Yes | Yes | Community | |
AGPL-3.0 | Binary | Yes | Binary | Yes | |
GPL-3.0 | Server via Docker | Yes | Server via Docker | Yes | |
MPL/GPL-3.0 | Yes | Yes | Yes | No | |
GPL-2.0 | No | Yes | No | No | |
Freeware (closed) | No | No | Yes | No | |
Apache-2.0 | Yes | Yes | Yes | Manual | |
MIT | Yes | Yes | Yes | No |
What it does
| Tool | Job | Direction | Output / storage | Best for |
|---|---|---|---|---|
Sync | IMAP ⇄ Maildir | Maildir | Everyday local mirror | |
Backup + migrate | IMAP → disk | EML + JSON index | Portable file backup | |
Backup + archive | IMAP/M365 → disk | One .eml per message | Durable, tool-free archive | |
Retrieve | IMAP/POP3 → disk | Maildir / mbox / MDA | Scripted pulls | |
Sync | IMAP ⇄ Maildir | Maildir | IDLE sync, many accounts | |
Retrieve/forward | IMAP/POP3 → MDA | Whatever the MDA does | Veteran Unix pipelines | |
Migrate + backup | IMAP → IMAP | Second mailbox | Provider migrations | |
Backup/sync | IMAP/Maildir ⇄ Dovecot | Dovecot store | Self-hosted mail servers | |
Archive platform | IMAP/M365/Gmail → archive | Postgres + Meilisearch | Searchable team archive | |
Archive platform | Journaling → archive | Dedup store + index | Compliance archiving | |
Archive platform | Mail flow → archive | Java store + index | Small-business archive | |
Archive server | IMAP → server | Tantivy + blob store | Self-hosted search server | |
Archive web app | IMAP/M365 → Postgres | Postgres + web UI | Team archive + retention | |
Export | Local cache → files | mbox / EML / PDF | Manual desktop export | |
Backup | Local store → tar.gz | Client archive | One-click Linux backup | |
Archive app | Accounts → archive | Local database | Windows home archive | |
Backup + restore | Gmail API ⇄ disk | mbox | Gmail power users | |
Archive + search | Gmail/IMAP/chat → archive | SQLite / DuckDB / Parquet | Lifetime searchable archive |
Which Email Backup Setup Is Right for You?
There’s no single winner here because „back up my email“ covers three genuinely different jobs, and the right pick depends on whether you want files you own, a searchable archive, or a quick export. Start with what you need, and if you’re not sure, the safe default is mbsync or imap-backup into a Maildir, plus restic on top.
- You just want your mail in files you own: mbsync on Linux/Mac/WSL, or imap-backup if you want the simplest possible cross-platform setup.
- You want an archive that’s just files, readable without any tool: mailvault — one
.emlper message, no database needed to read it, with an optional index only when you want to search. - You want scheduled, scripted pulls with delivery rules: getmail6.
- You’re migrating between providers: imapsync (server-to-server) or the migrate command in imap-backup.
- You run your own Dovecot server: doveadm backup — use it, don’t add another tool.
- You want a searchable, self-hosted archive with a web UI: Open Archiver or bichon for something modern, Mail-Archiver if you want retention rules and an access log, or piler for a more mature, compliance-focused setup.
- You’re a Windows-only user who wants a friendly app: MailStore Home (free, but closed source) or Thunderbird + ImportExportTools NG.
- You’re on Gmail: GYB for a restorable API-based backup, or Google Takeout for a one-off.
- You want a whole lifetime of mail searchable on your own machine: msgvault, a local-first archive you query with SQL, a TUI or a browser.
- You’re in Germany with audit obligations: a retention-capable archive — see the GoBD section — plus proper procedural documentation.
- Whatever you pick: point restic, kopia, Borg or Duplicati at the result so it isn’t a backup on a single disk.
Glossary
- IMAP
- Internet Message Access Protocol — the standard for accessing mail that lives on a server. Every tool in this guide either speaks IMAP directly or ingests mail that arrived through an IMAP-capable server.
- Maildir
- A mail storage format where every message is a separate file in a directory tree. It’s the portable, tool-friendly format that mbsync, offlineimap and getmail6 write, and what you want for a backup you can move around.
- mbox
- An older format where all messages in a folder live in a single file. Easy to import into almost anything, which is why Thunderbird, GYB and piler support it.
- EML
- A single message saved as a raw MIME file, complete with headers and attachments. The least-lossy, most portable unit of an email backup.
- Sync vs. backup vs. archive
- A sync (mbsync) keeps two mailboxes identical and mirrors deletions. A backup preserves a point-in-time copy. An archive is an append-only system of record with retention. Only the last two protect you from a mistaken delete.
- Journaling
- A mail-server feature that sends a copy of every message to an archive address. It’s how piler and Open Archiver capture mail completely and in real time, rather than polling a mailbox on a schedule.
- OAuth2 app password / email-oauth2-proxy
- Gmail and Microsoft 365 no longer allow plain IMAP password login. You use app passwords where available, or a local OAuth2 bridge like email-oauth2-proxy so older tools can still authenticate.
- GoBD
- The German principles for proper electronic bookkeeping and record retention (Grundsätze zur ordnungsmäßigen Führung und Aufbewahrung von Büchern, Aufzeichnungen und Unterlagen in elektronischer Form sowie zum Datenzugriff). They require tax-relevant records to be kept complete, unalterable and traceable, and to be available to auditors.
- WORM / immutability
- Write Once, Read Many storage — data can be written but not changed or deleted for a set period. A common technical way to satisfy audit requirements, sometimes via S3 Object Lock.
- Deduplication
- Storing identical content once. Mail archives dedupe heavily (the same message in several mailboxes, or repeated attachments), and backup tools like restic and Borg dedupe across snapshots.
- WSL
- Windows Subsystem for Linux — how you run Linux-only tools like mbsync on Windows.
FAQ
What is the best free open source way to back up IMAP email?
For most people, mbsync (isync) pulls IMAP into a local Maildir reliably on Linux, macOS and Windows via WSL, and imap-backup does the same job with an easier cross-platform setup and no config-file syntax to learn. Pair whichever you choose with restic or kopia so the local copy is also versioned and off-site.
Is mbsync better than offlineimap?
mbsync is usually faster and lighter on large mailboxes, and it’s a single C binary with almost no dependencies. offlineimap3 is the maintained Python 3 fork and supports IMAP IDLE for near-real-time sync. If you want raw speed and simplicity pick mbsync; if you want IDLE and a familiar Python config pick offlineimap3.
How do I back up Gmail?
Use Got Your Back (GYB), which backs Gmail up to local mbox files through the official Gmail API and can also restore messages and labels. Google Takeout is the zero-setup manual alternative. For IMAP-level access, mbsync or imap-backup work with an app password or an OAuth2 bridge.
How do I back up Outlook or Microsoft 365 mail?
Treat Microsoft 365 like any IMAP account: mbsync or imap-backup can pull it down, using OAuth2 via email-oauth2-proxy because Microsoft no longer accepts plain password logins. For a full corporate archive with retention, a self-hosted platform like Open Archiver or piler connects directly to Microsoft 365.
What is the difference between syncing and archiving email?
A sync tool like mbsync keeps a local copy identical to the server, including deletions, so a mistake on the server propagates. An archive is append-only: it captures mail and keeps it regardless of what happens on the server, with retention rules and search. Use a sync for convenience and an archive (or a versioned backup) for real protection.
Can I back up email without running my own mail server?
Yes. mbsync, imap-backup, getmail6, offlineimap3 and fetchmail all connect outward to any hosted IMAP account, so you don’t need a server. The self-hosted archiving platforms also connect to hosted mailboxes, either over IMAP or through Microsoft 365 and Google Workspace APIs.
What format should an email backup be in?
Maildir for a living local mailbox (it’s what most tools and clients expect), mbox for a single portable archive file, and individual EML files when you want per-message access. imap-backup writes EML, mbsync writes Maildir, and Thunderbird exports mbox or EML.
How do I restore an email backup?
It depends on the tool. imapsync and imap-backup can push mail into a new IMAP server, doveadm backup restores into Dovecot, and mbox or EML files import into most mail clients. Whatever you choose, test the restore before you need it, because an untested backup is only a hope.
Do I need Docker to self-host an email archive?
No, but it helps. Open Archiver is Docker-first and comes up with docker compose up. piler can be built from source, and MailArchiva runs as a normal Linux or Windows server. If you only want files on a disk, the command-line tools need no Docker at all.
Can I back up email on Windows?
Yes. imap-backup, getmail6, offlineimap3 and GYB run natively on Windows, mbsync runs under WSL, and Thunderbird with ImportExportTools NG and MailStore Home are native Windows apps. Docker Desktop also lets you run the self-hosted archivers on Windows.
What does GoBD require for email archiving?
For German businesses, tax-relevant emails must be kept complete, unalterable and traceable for the retention period, and made searchable and exportable for auditors. Business correspondence is generally six years and accounting documents longer, with the 2025 BEG IV reform shortening most voucher retention to eight years. You also need written procedural documentation, which no tool provides for you.
Is a self-hosted email archive the same as a backup?
No. An archive is a system of record optimized for retention, search and audit; a backup is optimized for restoring lost data quickly. Serious setups do both: an archive for compliance and history, and a versioned backup of the archive itself so the archive can be recovered.
