---
title: "Using Neon branching for instant Point in time recovery"
description: "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)."
url: "https://swe.quest/articles/using-neon-branching-for-instant-point-in-time-recovery-9f84c3c887a11e14"
canonical: "https://neon.com/blog/point-in-time-recovery"
source: "Neon"
published: "2023-07-28"
difficulty: "medium"
kind: "How-to"
reading_minutes: 4
tags: ["postgres","serverless","typescript"]
---

# Using Neon branching for instant Point in time recovery

A post on [Neon](https://swe.quest/sources/neon.md), published 2023-07-28, 4 min read, How-to. Original: [https://neon.com/blog/point-in-time-recovery](https://neon.com/blog/point-in-time-recovery)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Serverless](https://swe.quest/tags/serverless.md) (Backend & APIs)
- [TypeScript](https://swe.quest/tags/typescript.md) (Languages)

## Prerequisites

- PostgreSQL basics ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- Write-ahead logging ([easy posts on Observability](https://swe.quest/tags/observability.md?difficulty=easy))

## Keywords

Neon, Neon branching, Neon API, point-in-time recovery, WAL, LSN

## Related posts

- [Time Travel with Serverless Postgres](https://swe.quest/articles/time-travel-with-serverless-postgres-ce3e12c8b6286e70.md): Neon · 2022-12-07 · Medium · 9 min read · PostgreSQL, Serverless, Databases, Algorithms
  Neon's copy-on-write database branching can recover from accidental data loss by creating branches at a past point in time or at a specific Postgres WAL Log Sequence Number (LSN).
- [Announcing Point-in-Time Restore](https://swe.quest/articles/announcing-point-in-time-restore-fde22da262d059a9.md): Neon · 2024-02-20 · Medium · 5 min read · PostgreSQL, Serverless
  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.
- [Practical Guide to Database Branching](https://swe.quest/articles/practical-guide-to-database-branching-8aa2f63325bcfecb.md): Neon · 2025-12-04 · Medium · 9 min read · PostgreSQL, Databases, CI/CD, Schema migrations, Testing
  Neon's copy-on-write storage makes Postgres database branches instant and cheap: each branch shares the parent's base data, gets its own autoscaling compute that scales to zero, and can be created from any point within the history retention window.
- [Point In Time Recovery Under the Hood in Serverless Postgres](https://swe.quest/articles/point-in-time-recovery-under-the-hood-in-serverless-postgres-81b0a26592d229ce.md): Neon · 2024-02-22 · Medium · 7 min read · PostgreSQL, Storage engines, Serverless, Replication
  Neon implements point-in-time recovery by treating Postgres as its WAL.
- [I Dropped a Table in Production—Now What?](https://swe.quest/articles/i-dropped-a-table-in-production-now-what-e098e81a35749033.md): Neon · 2025-02-18 · Medium · 7 min read · PostgreSQL, Databases, Incidents & postmortems
  Neon's instant point-in-time recovery creates a new copy-on-write branch at a moment just before a dropped table.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
