imapvault

Every state of your mailbox, kept safe.

Open-source IMAP backup with point-in-time snapshots. imapvault keeps deleted mail for a grace period, notices when a mass deletion happens, and restores any snapshot, folder or message.

For the bad day

Someone gets into your account, deletes everything and empties the trash. A mirror copies that deletion. imapvault does not: the next run notices, raises an alert, pins the last good snapshot and exits with code 3. imapvault restore puts the mail back.

How it works

  1. backup reads the mailbox in one read-only session and stores each distinct message once, compressed and, if you want, encrypted with age.
  2. Every run is a snapshot: a cheap index of what was where, with flags. Moves and renames cost no extra storage.
  3. The guard compares each run with the last one. Too many deletions, or a vanished folder, flags the snapshot, pins the previous one and runs your alert command.
  4. forget and prune apply a retention policy. Mail deleted from the server stays restorable for 180 days by default, and pins and open alerts always win.
  5. restore shows exactly what it would add, then waits for a plan token you copy from the preview.
# every hour, from cron or a systemd timer
imapvault --account personal backup

# what changed between two snapshots
imapvault --account personal diff latest~1 latest

# undo the hack: preview first, then approve with the token it prints
imapvault --account personal restore --deleted-since 7d --in-place

Careful with your mail

Install

One static binary for Linux and macOS, on amd64 and arm64. The script checks the download against the published checksums before it installs anything, and puts imapvault in ~/.local/bin.

curl -fsSL https://imapvault.sh/install.sh | sh

Or brew install michele/imapvault/imapvault, or the container image ghcr.io/michele/imapvault. Prefer to read the script first? install.sh is short. You can also take an archive from the releases page. The macOS binaries are not signed, so Gatekeeper refuses the first run: xattr -d com.apple.quarantine imapvault. To run it on a schedule, see the systemd units and cron notes or the Docker guide.

Status

Version 0.1, alpha. Backup has run against a dovecot test server and a Fastmail mailbox. Restore has only been run against the test server, so try it on a throwaway account before you point it at a mailbox you care about.

Use it at your own risk. It is released under the MIT licence with no warranty, and a backup you have never restored is a hope, not a backup.

What is and is not verified is listed milestone by milestone in the plan.