Encrypted backups

ButlerDB can encrypt backups before they leave the server, so a leaked bucket, a stolen drive or a curious storage provider sees nothing but noise. Encryption uses age, an open format with a standard command-line tool, so your backups never depend on ButlerDB to be read.

1. Same serverNothing to do. Restores, restore tests and downloads decrypt automatically.
2. New serverAdd the recovery key to ButlerDB on the new server, then restore as usual.
3. No ButlerDBDecrypt with the age tool and the recovery key, then use the engine's own tools.

How it works

Each server has two keys. Every encrypted backup is encrypted to both, and either one opens it:

Encryption is chosen per destination: encrypt the S3 bucket and leave the external drive in the rack plain, for example. On an encrypted destination each backup is stored as <id>.tar.zst.age instead of <id>.tar.zst, next to its <id>.json record. The record stays readable so the destination can be listed and pruned without a key; it holds no secrets, only the backup's time, kind, size, checksums and engine. Checksums cover both the encrypted file and the archive inside it, so damage or tampering stops a restore instead of producing a broken database.

Continuous replication of SQLite databases (Litestream) can't be encrypted, so it's never sent to a destination with encryption on; replicate to one without it, or keep that database on encrypted snapshots alone.

What it protects against: anyone who gets the stored backups but not the server. What it doesn't: someone who controls the server itself, since the server key is there (and so are the databases).

Turning it on

In the app

  1. Open Backup Destinations for the server and choose Set Up Encryption….
  2. Save the recovery key: Copy it into a password manager, or Save to File… and move the file somewhere other than the server. Tick that you've saved it, then Done.
  3. Switch on Encrypt for each destination that should be encrypted. Backups already stored there stay as they are; new ones are encrypted.

From the command line

butlerdb backup encryption enable --save ~/recovery-key.txt
butlerdb destination encrypt offsite on
# or when adding one:
butlerdb destination add-s3 offsite --endpoint … --bucket … --access-key … --encrypt

The recovery key looks like this (a standard age key file):

# created: 2026-11-03T15:04:05Z
# ButlerDB recovery key: opens this server's encrypted backups. Keep it somewhere other than the server.
# public key: age1…
AGE-SECRET-KEY-1…

Without the recovery key, a lost server's encrypted backups can't be recovered, by you or by anyone else. Store it the way you'd store the root password to production: a password manager, or printed and put away, and never only on the server it protects.

To make a new recovery key (say, someone who had the old one left), run butlerdb backup encryption enable --replace-recovery-key or choose Keys › Replace Recovery Key… in the app. Backups made from then on use the new key; earlier ones still open with the old recovery key or the server.

1. Restoring on the same server

Nothing changes. Restore, single-database restore, restore tests and ready-to-start downloads decrypt with the server key as they stream. A raw download is the backup exactly as stored, so from an encrypted destination it stays encrypted.

2. Restoring on a new server with ButlerDB

When the original server is gone, install ButlerDB on a new one and point it at the same storage. Its catalog is empty, so read the backups from the destination itself.

In the app

  1. In Backup Destinations, add the destination with the same settings (same bucket and prefix, same SFTP folder, or the same drive).
  2. Right-click it and choose Browse Backups…, enter the instance's name from the old server (for example pg) and choose Find Backups. Encrypted ones show a lock; an orange lock means this server doesn't have the key yet.
  3. Choose Restore… on a backup. When asked, paste the recovery key (or choose its file). It's added to the server and the restore continues, into a new instance.

From the command line

butlerdb destination add-s3 offsite --endpoint … --bucket … --access-key …
butlerdb backup encryption add-key --file ~/recovery-key.txt
butlerdb backup list pg --from offsite
butlerdb backup restore pg 20261103T020000Z-full --from offsite --as pg
# a SQLite database restores to a file instead:
butlerdb sqlite restore app-db 20261103T020000Z-full --from offsite --to ~/app.sqlite

An added recovery key stays on the new server, so later restores and restore tests of those backups work too. Remove it when you no longer need it: butlerdb backup encryption remove-key age1… (butlerdb backup encryption lists the keys). To keep using the destination for new backups from this server, take it over with butlerdb destination take-over offsite pg --yes, and turn on encryption for this server with its own new recovery key.

3. Decrypting without ButlerDB

Every encrypted backup is a standard age file. With the recovery key and two common tools, anyone can get the archive back on any Mac or Linux machine:

# macOS
brew install age zstd
# Ubuntu / Debian
sudo apt install age zstd

Copy the backup's files from the destination (they're in a folder named after the instance: <destination>/<instance>/, under the bucket's prefix on S3), then:

mkdir 20261103T020000Z-full
age -d -i recovery-key.txt 20261103T020000Z-full.tar.zst.age \
  | zstd -d | tar -x -C 20261103T020000Z-full

The folder now holds exactly what an unencrypted backup holds. The record (<id>.json) says the engine, its version and, for an incremental, which full it builds on (base). Each restore needs at most two backups, a full and one incremental, never a longer chain.

EngineWhat's insideTo get a running server
PostgreSQLA pg_basebackup data directory (plain format, WAL included) Full: start it with the same major version. Incremental: pg_combinebackup full incr -o restored, then start restored.
MySQLA Percona XtraBackup directory xtrabackup --prepare --target-dir=full (with an incremental: --apply-log-only on the full first, then --prepare --target-dir=full --incremental-dir=incr), then start MySQL on it.
Valkeydump.rdb and users.acl Start Valkey with --dir pointing at the folder and --aclfile at users.acl.
ClickHouseA native BACKUP folder RESTORE … FROM File(…), with the full as base_backup for an incremental.
TypesenseA Typesense snapshot Start Typesense with its data directory on the snapshot.
SQLitedatabase.sqliteCopy it where the app expects its database.

The server key works the same way (age -d -i server.key) if you can still reach the old server's disk: it's Destinations/encryption/server.key under /Library/Application Support/ButlerDB on macOS or /var/lib/butlerdb on Linux.