Restore card — the forge back on a fresh machine
Print this. Keep it somewhere that is not the forge.
Have ready
- The passphrase (
FORGE_SNAPSHOT_PASSPHRASE). Without it every sealed value is lost and set again by hand; the rest restores. - The store address: the directory (
FORGE_SNAPSHOT_DIR) or the bucket (S3_ENDPOINT,S3_BUCKET,S3_ACCESS_KEY,S3_SECRET_KEY,S3_REGION; export them in place of line 3). - The keys: access to the forge's git remote and the store's credentials. The forge's own host key and secret key come out of the snapshot.
- A machine with
git,bunand an empty data directory.
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.
git clone https://forge.open-platform.sh/trevato/forge.git forge && cd forge # networkbun install # networkexport FORGE_SNAPSHOT_DIR=<store-dir>export FORGE_SNAPSHOT_PASSPHRASE=<passphrase>bun run src/snapshot/restore.ts latest <data-dir>test -s <data-dir>/forge.dbFORGE_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.
- On the web. Settings, Backups: Read-only key seals a key made in the bucket's console (read and list only) and tests it; Recovery kit says whether a kit can be made, when it was last downloaded, whether that still fits, and how the outside drill went. Download the kit is a POST, an admin's, same-origin, an attachment, never cached.
- In the terminal. Palette: Recovery kit (admins).
kseals the read-only key from two masked prompts;dshows the kit's text to copy off the machine and records the take. Both go throughsrc/actions/destination.ts, so the page and the terminal share the gate and thebackup.read_key_sealedandbackup.kit_downloadedevents the page follows live. - The outside drill. After each green inside drill, and after it has reported, a fresh process
restores the newest snapshot from the kit and the passphrase alone and the forge is booted. Its
record is
drill/outside.json;backup.outside_drilledtells the page. - The verdict. A forge whose destination is sealed here reads unknown ("inside drill only"), not red, until that has passed; no card, release or issue gates on it. A failed outside drill is red.