Restore card — the forge back on a fresh machine

Print this. Keep it somewhere that is not the forge.

Have ready

The lines

Replace <store-dir>, <data-dir> and <passphrase>. A line ending # network needs the network and # boot starts the forge and does not return; test/restore-card.test.ts runs every other line against a test snapshot, so this card cannot drift from the command.

  1. git clone https://forge.open-platform.sh/trevato/forge.git forge && cd forge # network
  2. bun install # network
  3. export FORGE_SNAPSHOT_DIR=<store-dir>
  4. export FORGE_SNAPSHOT_PASSPHRASE=<passphrase>
  5. bun run src/snapshot/restore.ts latest <data-dir>
  6. test -s <data-dir>/forge.db
  7. FORGE_DATA=<data-dir> bun run src/main.ts # boot

The restore prints what it brought back. A wrong passphrase refuses before writing anything; a missing one restores without the key and lists the sealed values to set again. To pick an older snapshot, put its name (2026-09-22T08-00-00Z) where line 5 says latest. Details: SNAPSHOT.md.

On a box that stays: scripts/box-install.sh, then lines 3–6 as the forge user with <data-dir> /var/lib/forge, then systemctl enable --now forge in place of line 7 (EXTRACT.md, _The box beside production_).

When the forge is gone: the recovery kit

The bucket's address and keys are sealed inside the forge's own database, so a lost machine takes them with it. The Backups page's Recovery kit keeps a copy that does not live there: one JSON file with the endpoint, bucket, a read-only key (made in the bucket's console and sealed on that page; the forge's own read-write key never goes in it), whether the snapshots are sealed and the command below. The passphrase is not in it, and nothing derived from it either: a value to check a guess against would let whoever holds the kit guess offline. A wrong passphrase is refused by the restore itself, from the sealed lane's header or the snapshot's wrapped key. Download the kit, keep it off the machine, and keep the passphrase somewhere else again. The page (and the terminal's Recovery kit screen) says when it was last downloaded and whether it still matches the destination.

On a clean machine with the release checkout and an empty data directory, the kit and the passphrase are all it takes:

FORGE_SNAPSHOT_PASSPHRASE=<passphrase> bun run src/snapshot/restore.ts latest <data-dir> --kit <kit-file> FORGE_DATA=<data-dir> bun run src/main.ts

After each green inside drill the forge runs the same restore from the kit alone, in a fresh process with no S3_*, no FORGE_* and no data directory of its own, then boots what came back: the outside drill. The Backups verdict of a forge whose destination is sealed in its own database is unknown (never red, never a card) while only the inside drill has passed, until a read-only key is sealed and an outside drill passes; it says which modes have (restore drill … passed, inside and outside). A forge whose bucket comes from the host's environment keeps its keys outside the database and owes no outside drill. The drill runs after the inside drill has reported, so a slow kit restore never delays it. test/recovery-kit.test.ts runs both.

The drill on the box

scripts/restore-drill.ts runs lines 3–7 and checks them, from the bucket alone: with the card's S3_* lines and the passphrase exported, as the forge user,

bun scripts/restore-drill.ts <empty-data-dir>

restores the newest snapshot into that directory, boots it on a free side port, checks / answers, and prints the repositories and apps anyone can see beside production's public API (--production <url>, default https://forge.open-platform.sh); the restored forge boots as a preview, so the sample its preview admin seeds is left out. It exits 1 when a step fails or a count differs. It writes only into the directory it is given, which must be empty, refuses /data, and leaves the restored copy in place. test/restore-drill-script.test.ts runs it against a tiny snapshot and a stub bucket.

From the off-site lane

The forge's own sealed backup lane (#11805), how to restore from it and how it is drilled: features/offsite-lane.md.

With the platform unreachable (the B2 mirror only): backup-truth.md, _Leaving the platform_.

How the kit is made and proved

The bucket's address and keys are sealed in the database the snapshots back up, so a lost machine takes them along. The kit is the copy kept elsewhere: one JSON file with the endpoint, bucket, region, a read-only key and the command. No passphrase, and nothing derived from it.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs