Operations · Engineering
Point-in-time recovery without guessing
How snapshot plus WAL replay reaches a chosen timestamp, what the recovery window costs, and when writes stop.
A backup restores to the moment it was taken. An accidental delete at 12:03 needs a recovery point at 12:02, not last night’s copy. That is point-in-time recovery.
NonoDB’s PITR is opt-in and per database. It combines a consistent snapshot with retained WAL history after that snapshot.
Enable it
NONODB_PITR_ENABLED=1NONODB_SNAPSHOT_DIR=/var/backups/nonodb/snapshotsNONODB_SNAPSHOT_INTERVAL=300NONODB_PITR_WINDOW_SECS=604800NONODB_WAL_SEGMENT_BYTES=64MiBNONODB_WAL_MAX_BYTES=20GiBNONODB_PITR_ENABLED defaults to 0. With it enabled and NONODB_SNAPSHOT_DIR unset, snapshots are written below <NONODB_DATA>/<database>/snapshots.
| Variable | Default | Meaning |
|---|---|---|
NONODB_PITR_ENABLED |
0 |
Enables WAL archiving and PITR retention |
NONODB_PITR_WINDOW_SECS |
604800 |
Retained recovery window (7 days) |
NONODB_WAL_MAX_AGE_SECS |
PITR window | Hard maximum WAL age |
NONODB_WAL_SEGMENT_BYTES |
64MiB |
Target segment size |
NONODB_WAL_MAX_BYTES |
20GiB |
Hard per-database WAL limit |
NONODB_SNAPSHOT_INTERVAL |
300 |
Snapshot interval |
NONODB_SNAPSHOT_KEEP |
24 |
Snapshot count when PITR is off |
Snapshots and WAL are local to each database. They are not an instance-wide atomic recovery point.
Retention
Retention keeps the oldest snapshot needed by the recovery window and the newest snapshot. WAL segments are removed only after a successful, fsynced snapshot covers them. A snapshot without its metadata marker is never used to prune WAL.
At 80% of the size limit, or when the age limit is reached, the daemon requests a snapshot. At the hard limit, new writes are rejected with wal_full instead of silently discarding history. Reads remain available. Once retention removes covered segments, writes resume automatically.
That is the honest trade-off: disk is bounded, and the write path fails closed rather than pretending history is intact.
Restore to a timestamp
Stop the daemon first:
systemctl stop nonodb
nonodb-cli --db app1 restore --to 2026-01-01T12:00:00Z \ /var/backups/nonodb/snapshots /var/lib/nonodb \ --wal /var/lib/nonodb/app1/wal \ --force --verify--toaccepts RFC 3339, Unix milliseconds, or Unix seconds.- The snapshot root contains
<root>/<database>/data-<unix-ms>.mdband its metadata. --walmay be omitted for an in-place restore; the default is<target-database>/wal.- The command selects only a snapshot at or before the target.
- A future target or a target older than the retained base fails.
- A WAL gap fails instead of returning a silently incomplete history.
--verifychecks the database after replay.
Start the daemon and verify documents, indexes, and search sidecars.
If the snapshot is already in place and you want replay on open, set NONODB_PITR_REPLAY_TO. Replay runs before the writer accepts requests and is idempotent across restarts. Restore the matching snapshot first; a target newer than the current data is not a rollback.
When a WAL is newer than the database
After an in-place restore, the daemon may find a WAL from the discarded future. At the next start it moves the superseded WAL aside as <database>/wal.superseded-<unix-ms> and starts a new history instead of reusing sequences.
That prevents a restored database from reapplying writes that belong to a timeline you intentionally abandoned.
Metrics and alerts
PITR exposes per-database metrics:
| Metric | Meaning |
|---|---|
nonodb_wal_bytes |
Bytes used by retained segments |
nonodb_wal_oldest_age_seconds |
Age of the oldest retained segment |
nonodb_wal_last_sequence |
Highest archived sequence |
nonodb_wal_full |
1 while the hard limit rejects writes |
nonodb_pitr_available |
1 when snapshot plus WAL can serve a restore |
nonodb_wal_pruned_bytes_total |
Bytes removed by covered retention |
Alert on wal_full == 1 and on pitr_available == 0 while last_sequence > 0. A busy WAL above 80% for long means snapshots are not completing or the window is larger than the disk budget.
Scope and limits
- PITR covers one database at a time.
- It does not include
auth.json, audit logs, vault tenant keys, or node-local settings. - Search and vector sidecars come from the snapshot and are rebuilt when missing; the WAL carries document and index metadata, not sidecar bytes.
- Do not restore under a running daemon.
- The recovery window is limited by both time and disk.
Test it before you need it
A PITR drill:
- Write a known marker document.
- Wait for a snapshot.
- Write another marker, then delete the first.
- Restore to a timestamp between the writes.
- Verify the first exists and the delete is absent.
- Verify indexes and search.
If the drill takes an afternoon, the incident will take longer.
The PITR guide and backup guide cover the exact flags, metrics, and retention behavior.