Keenrig

Backups and restore

Today, backups run as commands on the server. Every backup is encrypted, and you choose where it goes. Read the last section before you rely on them: some things are not covered yet.

What a backup contains

A backup is an encrypted snapshot of the whole Keenrig instance: its settings and database, its keys, and the files of every installed app. It always contains the server’s own keys, which is why encryption cannot be turned off.

Not covered yet: data in app add-on databases (PostgreSQL, Redis). If an app keeps its data there, the backup does not include that data.

Choose where backups go

There is no default destination, on purpose: a default would quietly write backups to the server’s own disk, which is lost at the same moment as what it protects. Set these variables as root before you run any backup command:

  • KEENRIG_BACKUP_TARGET — dir (a folder, including a mounted NAS) or s3
  • KEENRIG_BACKUP_CONFIG — for dir, an absolute path such as /mnt/nas/keenrig; for s3, s3://<bucket>/<prefix>?region=<region>&endpoint=<url>
  • KEENRIG_BACKUP_PASSPHRASE — the passphrase that encrypts every backup

For S3, also set KEENRIG_BACKUP_S3_KEY_ID and KEENRIG_BACKUP_S3_SECRET. Leave out endpoint for Amazon S3; set it for another S3-compatible service. Unknown options in the address are refused rather than ignored, so a typo cannot silently send your backup somewhere else.

Keenrig never stores your passphrase. Without it, backups cannot be restored. Keep it somewhere other than this server.

Back up now

Run as root (sudo -i). The Backups page in the admin panel shows the same commands, ready to copy.

/var/lib/keenrig/bin/keenrig-box backup --data /var/lib/keenrig

It prints the snapshot ID, how many parts were stored, the size and the destination.

List backups

Lists every complete snapshot on the destination with its ID, size and date. It needs no passphrase.

/var/lib/keenrig/bin/keenrig-box backups

Restore one app

Restores a single app on this server from a snapshot. Use the app ID, not its name. The instance database is left untouched. Leave out --from to use the newest complete snapshot.

/var/lib/keenrig/bin/keenrig-box restore --data /var/lib/keenrig --from <snapshot-id> --app <app-id>

Move to a new server

Restores the whole instance. Use it on a clean machine only, with the same three variables set as on the old server.

/var/lib/keenrig/bin/keenrig-box restore --data /var/lib/keenrig --from <snapshot-id>

The command refuses to run when the destination already holds data, and there is no force flag: move the old directory aside yourself if you really mean to replace it. When it finishes, start keenrig-box and the apps come back up on their own.

Not covered yet

These are in progress. Until they ship, the commands above are the whole backup feature.

  • Data in app add-on databases (PostgreSQL, Redis).
  • An automatic schedule: nothing runs on its own yet. Run a backup yourself before big changes, or call the backup command from your own cron job or systemd timer with the same variables set.
  • Choosing a destination and restoring from the admin panel.
  • Managed backup storage run by Keenrig.