Skip to content

Backup & Restore

Back up the database, secret key and manifest into one archive, and restore it safely.

pigeon backup writes a gzip-compressed tar archive with everything needed to restore an instance. It is a CLI-only command — no server or API is involved; like pigeon digest, it opens the data directory directly.

pigeon backup                        # writes ./pigeon-backup-YYYYMMDD-HHMMSS.tar.gz
pigeon backup -o /backup/pigeon.tar.gz

What’s inside

File Contents
pigeon.db Consistent SQLite snapshot: accounts, cached mail, attachments, settings and tokens
secret.key The AES-256-GCM key that decrypts account passwords
manifest.json Archive format version, app version, creation time and a SHA-256 checksum per file

Run logs under <data-dir>/logs are not included.

The snapshot uses SQLite’s VACUUM INTO, so the server can keep running during the backup. Prefer quiet periods for large mailboxes — a long snapshot delays WAL checkpoints.

Flags

Flag Default Description
-o ./pigeon-backup-<timestamp>.tar.gz Output file; must not exist
--data ~/.pigeon Data directory

The command refuses to run when pigeon.db or secret.key is missing: creating a fresh key for an existing database would produce an archive whose passwords can never be decrypted again. The output file is created with 0600 permissions, an existing file is never overwritten, and a failed run removes its partial output.

Security

The archive contains the key that decrypts your mail passwords — treat it like a password. Encrypt it (for example with age or gpg) before storing it off-site, and check the checksums in manifest.json after moving it:

sha256sum pigeon.db secret.key   # compare with manifest.json

Restoring a backup

Use pigeon restore to unpack a backup back into a data directory:

pigeon restore -f pigeon-backup-20261204-153005.tar.gz            # restore into ~/.pigeon
pigeon restore --data /srv/pigeon -f /backup/pigeon.tar.gz

It verifies every file against the SHA-256 checksums in manifest.json, checks that secret.key is 32 bytes and that the database passes SQLite’s integrity_check, and only then installs the files. The target directory must not already contain pigeon.db, secret.key or leftover -wal/-shm files — the command refuses rather than overwrite. A missing data directory is created with 0700.

A typical restore over an existing instance:

  1. Stop the running server (pigeon serve / pigeon mcp).

  2. Move or delete the old state files:

    cd ~/.pigeon
    rm -f pigeon.db pigeon.db-wal pigeon.db-shm secret.key
  3. Restore and start again:

    pigeon restore -f /path/to/pigeon-backup-20261204-153005.tar.gz
    pigeon serve

The archive keeps each file’s 0600 mode; run the restore as the same user that runs Pigeon. If you prefer, the archive is a plain tar.gz and can still be unpacked by hand.