Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Neon 7 min read Deep dive mediumAdept

Point In Time Recovery Under the Hood in Serverless Postgres

Neon implements point-in-time recovery by treating Postgres as its WAL. WAL is streamed to Paxos-backed Safekeepers, then to multi-tenant Pageservers that build immutable image and delta layers keyed by key range and LSN. The post contrasts this with traditional Postgres PITR, which needs base backups, WAL archiving, tools like Barman and a standby server. Neon's GetPage@LSN instead rebuilds any page at any LSN on demand. Time Travel Assist uses this through ephemeral copy-on-write branches with a 10-second TTL, so you can query a past state before restoring.

Related posts

  • A Deep Dive Into Neon’s Instant PITR

    Neon mediumAdept

    Neon's point-in-time restore is instant because its storage is copy-on-write: compute nodes stream WAL to Paxos-replicated safekeepers, and pageservers reconstruct any page at any past LSN from image and delta layers kept in object storage. A restore maps the requested timestamp to an LSN and creates a new branch that references existing layers through GetPage@LSN, so no data is copied. That makes restores take under a second regardless of database size, compared with RDS-style restores that load a snapshot into a new instance and replay WAL, which can take hours for multi-TB databases.

  • Architecture decisions in Neon

    Neon mediumAdept

    Neon built serverless Postgres by separating storage from compute without forking Postgres. Postgres streams WAL over the network to a separate WAL service of safekeeper nodes, which use consensus for durability and to prevent split-brain. Multi-tenant pageservers rebuild any page version on request. All historical page versions are kept in immutable, LSM-inspired files that are compressed and offloaded to object storage like S3, which replaces traditional backups and WAL archives and makes point-in-time recovery and branching cheap.

  • Announcing Point-in-Time Restore

    Neon mediumAdept

    Neon's Branch Restore feature, now in the Neon Console, restores a Postgres branch to any LSN or timestamp within a configurable history retention window of up to 30 days. This is possible because Neon's separated storage and compute retain WAL history. Time Travel Assist lets you query the database as it was at a chosen point before committing, so you can pinpoint when data loss happened. Restores take a few seconds and briefly drop connections, much like a cold start. The post contrasts this with self-managed approaches: pg_dump offers no point-in-time recovery, while pg_basebackup with WAL archiving, pgBackRest or Barman can do it but cost operational effort.

  • Deep dive into Neon storage engine

    Neon hardMaster

    Neon's storage engine separates Postgres compute from storage and serves pages through GetPage@LSN, reconstructing any page as of any log sequence number from immutable layer files. WAL streams from Postgres to three Paxos-backed safekeepers, then to pageservers that buffer about 1GB of WAL before writing delta layers, building image layers in the background and uploading everything to S3 or GCS. The design borrows from LSM trees but keeps long-lived history, which enables point-in-time restore, copy-on-write branching and fast serverless cold starts without traditional backups or WAL archiving. Compaction and garbage collection bound read cost and retained history, and cold key ranges settle into image layers only.

  • Using Neon branching for instant Point in time recovery

    Neon mediumAdept

    Neon's copy-on-write branching can restore a Postgres database to an earlier point in time by creating a branch from a timestamp or LSN within the retained WAL history window (seven days by default). Creating the branch from the console gives you a new compute endpoint and so a new connection string. To keep the existing connection string, a TypeScript script using the Neon API client creates an endpoint-less branch at the target timestamp, reassigns the existing compute endpoint to it, and sets it as the primary branch. Afterward, rename the old branch and delete its data to avoid storage charges.

The quest for software engineering knowledge.

Look:
Layout: