Restore into a fresh data directory and an isolated environment. Keep application writers pointed at the existing cluster until the recovered cluster passes both Ledger integrity checks and your business checks.
Ledger provides two restore workflows:
| Workflow | Use it when |
|---|---|
| Restore service | An operator needs separate download, validation, preview, and finalization gates |
| Offline bootstrap | Automation needs to build a ready data directory with one command and no running Ledger server |
Both workflows support S3, S3-compatible storage, and Azure Blob Storage. Both apply incremental segments after the full checkpoint before they finalize the recovered state.
Before you start#
Record:
- the chosen full backup and every incremental segment that follows it;
- the expected last log and audit sequences;
- the Ledger release used to create the backup and the release selected for restore;
- the target cluster identity, storage paths, and security configuration;
- the application workflows and balances that must pass before cutover.
Persisted-format compatibility depends on the Ledger release. Restore with a release combination that you have tested. Do not assume that development or prerelease builds can exchange persisted data.
Use a dedicated target path. Before either workflow starts, Ledger checks for state that could make a normal startup select stale data under a restored boundary:
| Guard | Required state |
|---|---|
RESTORED | The marker must not exist. Its presence means a restore has already committed. |
live/, live.staging/, live.discard/ | None of these directories may exist. |
checkpoints/ | No numbered checkpoint may exist. The only recoverable exception is an orphaned checkpoints/0 with no marker and no live* directory; Ledger removes that half-finalized checkpoint before retrying. |
Do not copy a backup over an existing data directory to bypass these guards. Use another path when the ownership of a leftover directory is unclear.
Use the restore service#
1. Start restore mode#
Start one node with a fresh data directory. Do not combine --restore with --bootstrap or --join.
Restore RPCs are unauthenticated and bind to 127.0.0.1 by default. Keep this default for local operations. If you must expose restore mode remotely, restrict network access and configure TLS before changing --restore-listen.
2. Download the recovery set#
From S3:
From Azure Blob Storage:
The command starts a server-side download and reports progress until it reaches a terminal state. --insecure is required here because this local example starts the restore service without TLS.
If the command is interrupted with Ctrl+C, Ledger cancels the server-side job and clears its staging directory. A failed download also clears staging. Retry restore download against the same running restore service; you do not need to restart it.
3. Validate the staged data#
Validation checks the staged log sequence and compares replayed volumes and metadata with the staged state. It returns a non-zero exit code when it finds an integrity error.
This check does not validate your external event consumers, application database, access policies, business-level aggregates, or Ledger's local usage projection. The backup does not contain <data-dir>/usage/usagedb; Ledger reconstructs those counters and Numscript template-usage records after normal startup.
4. Preview the recovery point#
Record the previewed:
- last applied index and timestamp;
- last log sequence;
- ledger names and count.
Compare the last log sequence with the boundary recorded by the selected backup chain. Stop if the preview identifies a different recovery set.
5. Finalize and restart#
Finalization first places checkpoints/0, then atomically writes RESTORED. The marker is the commit point. After the command succeeds, stop restore mode and start Ledger normally with a fresh WAL:
Ledger consumes the restore marker during the first normal startup and establishes the recovered state as the beginning of the new cluster history.
Resume after an interruption#
Use the filesystem state to decide what to do; do not rerun finalization blindly:
| State after interruption | Next action |
|---|---|
| Download failed or was canceled | Retry restore download against the running restore service. Staging was cleared. |
| Validation or preview failed | Keep traffic isolated. Fix the selected recovery set, download it again when needed, then repeat validation and preview. Do not finalize a mismatched set. |
RESTORED exists | Finalization committed. Do not restart in restore mode; start Ledger normally with --bootstrap and a fresh WAL. |
No marker, no live*, and only checkpoints/0 remains | Restart restore mode. Ledger recognizes and removes this single half-finalized checkpoint, then you can download and finalize again. |
| A marker write failed and Ledger reports that cleanup also failed | Remove only the exact checkpoints/0 path named in the error after confirming that RESTORED is absent, then restart restore mode. |
Any live/, live.staging/, live.discard/, or other checkpoint exists | Stop. Preserve the directory and use a new target path unless you have established where that state came from. |
The offline bootstrap command applies the same freshness guards. If it completed the RESTORED marker, proceed to normal startup. If it left only the recoverable checkpoints/0 state, rerunning bootstrap reclaims it; other leftovers require a fresh target path or an explicit investigation.
Use offline bootstrap#
Offline bootstrap downloads, applies incrementals, previews, optionally validates, and finalizes the recovered data directory without a restore server:
Review the preview before confirming. Use --yes only in automation that already verifies the selected bucket, expected sequences, target path, and command exit status.
After bootstrap completes, start Ledger normally with --bootstrap, the recovered data directory, and a fresh WAL directory as shown above.
Wait for usage statistics to catch up#
On every recovered member, Ledger creates a new local usage store and folds the audit entries available in the restored primary store. During this period, ledger statistics and Numscript template usage can be zero or incomplete even though transactions and balances are ready.
Monitor these gauges until the background fold completes:
Require formance.ledger.usage.builder.lag = 0 on every serving member before accepting those statistics. There is no public full-rebuild command in Ledger 3.0. Ledger 3.0 keeps audit history permanently in the primary store, so a restored store carries the full range and zero lag means the whole of it was processed.
Prove the recovery#
Do not route production traffic until you have captured evidence for each layer:
Ledger state#
ledgerctl store check --jsoncompletes without an integrity error;- the global log boundary matches the restore preview;
- expected ledgers exist;
- account and transaction counts match the recovery record;
- representative balances, metadata, references, and reversions match known values;
- required indexes have completed their backfill;
- usage-builder lag is zero on every serving member, and any historically incomplete usage figures are documented and reconciled where required.
Cluster operations#
- the cluster has a leader and the expected voting members;
- a controlled write and a current read succeed through the intended endpoint;
- authentication, authorization, request signing, response verification, and internal TLS behave as configured;
- monitoring and alerts identify the recovered cluster correctly.
Downstream systems#
- event-sink cursors are understood before delivery resumes;
- consumers tolerate replay from the selected boundary;
- reconciliation against the application source of truth passes.
Rehearse disaster recovery#
Run the complete procedure on a schedule with production-scale data. Record:
- backup identifiers and sequence boundaries;
- start and completion times for download, validation, startup, and application verification;
- the achieved recovery point and recovery time;
- every manual intervention;
- the final decision to accept or reject the recovered cluster.
A recovery exercise fails when the cluster starts but cannot prove the expected accounting state. Keep the original cluster and recovery artifacts unchanged until the investigation is complete.