Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/docs/content/docs/(index)/full-stack-tutorial.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Prisma ORM is optional on both products: Prisma Postgres works with any PostgreS
| Direct connections, per database | 45 |
| Automated backups | None |

Each SQL statement your app sends is one operation, whether it reads or writes, and `BEGIN` and `COMMIT` count too. See [What is an operation?](/postgres/faq#what-is-an-operation). Direct connections are the ones PostgreSQL tools such as `pg_dump` open. On Free, each database allows up to 45 of them, plus 500 pooled connections: each database has 50 Postgres connections, 5 are reserved for Prisma's internal admin access, and the pooler's own connections to Postgres (up to 25) count against the 45, so a busy pooler leaves 20 for direct connections. Connection limits are per database, not shared across the workspace; see [Connection limits](/postgres/database/connection-pooling#connection-limits). The Free plan has no automated backups, and Prisma Postgres cannot yet restore a database to an earlier point in time, so keep your own copies with `pg_dump`, the PostgreSQL command-line backup tool, over a direct connection. See [Backups](/postgres/database/backups).
Each SQL statement your app sends is one operation, whether it reads or writes, and `BEGIN` and `COMMIT` count too. See [What is an operation?](/postgres/faq#what-is-an-operation). Direct connections are the ones PostgreSQL tools such as `pg_dump` open. On Free, each database allows up to 45 of them, plus 500 pooled connections: each database has 50 Postgres connections, 5 are reserved for Prisma's internal admin access, and the pooler's own connections to Postgres (up to 25) count against the 45, so a busy pooler leaves 20 for direct connections. Connection limits are per database, not shared across the workspace; see [Connection limits](/postgres/database/connection-pooling#connection-limits). The Free plan has no automated backups, and [point-in-time recovery](/postgres/database/point-in-time-recovery) is on the Pro, Business and Enterprise plans only, so on Free keep your own copies with `pg_dump`, the PostgreSQL command-line backup tool, over a direct connection. See [Backups](/postgres/database/backups).

### Prisma Compute

Expand Down
3 changes: 2 additions & 1 deletion apps/docs/content/docs/ai/mcp-tools.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ Tools that change or delete resources can cause data loss or interrupt live traf
## Backups and recovery

- `list_prisma_postgres_backups`: List available automated backups for a Prisma Postgres database.
- `create_prisma_postgres_recovery`: Restore a Prisma Postgres database to a new database with the given backup id.
- `get_prisma_postgres_pitr_window`: Get the oldest and newest time a Prisma Postgres database can be restored to with point-in-time recovery. It needs the Pro, Business or Enterprise plan.
- `create_prisma_postgres_recovery`: Restore a Prisma Postgres database into a new database, from a backup id or, with `targetTime`, as it was at a point in time.

## Schema and queries

Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/postgres/database/backups.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ To recover rows that were deleted by mistake without overwriting newer data, [re
For more details about backup availability and plan-specific features, visit our [pricing page](https://www.prisma.io/pricing).

:::note
Point-in-time recovery is not available on Prisma Postgres yet. When it ships, it will restore a database to a moment you choose, rather than to a retained daily snapshot.
To restore a database to a time you choose, rather than to a daily snapshot, use [point-in-time recovery (PITR)](/postgres/database/point-in-time-recovery), on Pro (7 days) and Business and Enterprise (30 days).
:::

## Restoring a backup
Expand Down
1 change: 1 addition & 0 deletions apps/docs/content/docs/postgres/database/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"connection-pooling",
"query-insights",
"backups",
"point-in-time-recovery",
"postgres-extensions",
"serverless-driver"
]
Expand Down
101 changes: 101 additions & 0 deletions apps/docs/content/docs/postgres/database/point-in-time-recovery.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
---
title: Point-in-time recovery (PITR)
description: "Point-in-time recovery (PITR) for Prisma Postgres: restore to a timestamp in the last 7 days on Pro or 30 days on Business and Enterprise, into a new database."
metaTitle: "Point-in-time recovery (PITR) for Prisma Postgres: 7 or 30 days"
metaDescription: Prisma Postgres point-in-time recovery (PITR) restores a database to any timestamp in the last 7 days (Pro) or 30 days (Business, Enterprise), into a new database. Not on Free or Starter. Console, REST API and MCP.
url: /postgres/database/point-in-time-recovery
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
---

Prisma Postgres supports point-in-time recovery (PITR) on Pro (7 days) and on Business and Enterprise (30 days). It is not available on Free or Starter.

Point-in-time recovery (PITR) restores a Prisma Postgres database to a timestamp you choose, into a new database. Use it to get back rows that were deleted or changed by mistake. Unlike a [backup](/postgres/database/backups), it is not limited to the times of daily snapshots.

For example, if a migration deleted a column at 14:05, restore the database as it was at 14:04. Then copy the data you need back into the original database.

The restore always creates a new database. The original database is not changed, and your app keeps using it while the restore runs.

## Which plans have PITR, and how far back can you restore

Point-in-time recovery is available on the Pro, Business, and Enterprise plans. On those plans, the restore window is how far back you can go. Free and Starter do not have point-in-time recovery:

| Plan | Point-in-time recovery | What you can restore |
| ---------- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Free | No | Nothing. The Free plan has no backups. |
| Starter | No | A [daily backup](/postgres/database/backups), kept 7 days and taken on days the database has activity. You restore to a daily snapshot, not to a time you choose. |
| Pro | Yes | Any time in the last 7 days, from your earliest retained backup |
| Business | Yes | Any time in the last 30 days, from your earliest retained backup |
| Enterprise | Yes | Any time in the last 30 days, from your earliest retained backup |

On Pro, Business, and Enterprise, the newest time you can choose is 10 minutes ago. The oldest time is your earliest retained backup, so it can be later than the start of the window:

- A new database can be restored only after its first backup has finished.
- After you [restore a backup](/postgres/database/backups#restoring-a-backup) in place, you can only restore to times after the next backup that finishes.
- Some older databases do not support point-in-time recovery. Console says so on the database's **Point in time** page.

## Restore to a point in time in Console

To restore a database, you need the Admin role, or the Developer role with access to the project. See [Workspace roles and project access](/console/workspace-access).

1. Open the database in the [Prisma Console](https://console.prisma.io) and select **Point in time** in the sidebar.
2. Under **Choose Point in Time**, choose the date and time to restore to. The description under the label shows the oldest and newest times you can choose.
3. Optional: choose a different time zone in the list next to the date. Times are shown in your local time zone by default. The time zone changes only how the times are shown.
4. Under **Choose Database Name**, enter a name for the new database.
5. Click **Restore to new database**.

Console opens the new database's **Dashboard**, which shows that the database is being restored.

The new database is created in the same project, on the same branch, and in the same region as the original. It counts toward the database limit of your plan.

## While the restore runs

A restore can take several hours for a large database. While it runs:

- The new database's **Dashboard** shows the progress, and updates when the restore finishes. You can leave the page and come back later.
- The sidebar shows only **Dashboard** and **Settings** for the new database. You cannot open Studio, Queries, or connection strings until the restore finishes.
- On **Settings**, you cannot rename the database. For the first few minutes, you cannot delete it either. Console shows **This restore is still starting** until the delete is possible.

When the restore finishes, Prisma sends an email to the Admins and Developers who can access the project. If the restore fails, the email says so and links to the **Point in time** page, where you can try again. A failed restore can leave the new database incomplete. Open it from the email to keep or delete it. A restore that has not finished after 24 hours is marked as failed.

## Use the restored data

The new database has its own connection strings. The connection strings of the original database do not reach it.

1. [Generate a connection string](/postgres/database/connecting-to-your-database#get-your-connection-strings) for the new database.
2. Copy the rows you need back into the original database, or point your app at the new database.

[Recover deleted records from a hosted Postgres database](https://www.prisma.io/postgres/recover-deleted-records) walks through copying rows back.

When you no longer need the new database, delete it from its **Settings** page. If the database is on a branch that [Delete Protection](/console/delete-protection) covers, turn off **Data** first. In a workspace created through the Vercel integration, the Console can't delete it: use the Prisma CLI or the REST API, as described in [Deleting a restored copy in a Vercel workspace](/postgres/database/backups#deleting-a-restored-copy-in-a-vercel-workspace).

## Restore with the REST API or MCP tools

The REST API and [MCP tools](/ai/mcp-tools) use the same restore window as Console.

**REST API**

1. Call [`GET /v1/databases/{databaseId}/backups/pitr`](/rest-api/endpoints/database-backups/get-databases-by-database-id-backups-pitr) to read the oldest and newest times you can restore to. `window` is `null` when no time is available, and `meta.availableOnPlan` is `false` when your plan does not include point-in-time recovery.
2. Call [`POST /v1/projects/{projectId}/databases`](/rest-api/endpoints/databases/post-projects-by-project-id-databases) with a `source` of type `pitr`:

```json
{
"name": "orders-restored",
"source": {
"type": "pitr",
"databaseId": "db_123",
"targetTime": "2026-12-01T14:04:00Z"
}
}
```

`targetTime` is an ISO 8601 date and time inside the window.

**MCP tools**

- `get_prisma_postgres_pitr_window` returns the window of a database.
- `create_prisma_postgres_recovery` with a `targetTime` restores the database to a new database.

## Next steps

- [Backups](/postgres/database/backups): restore a daily snapshot, or restore a database in place.
- [Connecting to your database](/postgres/database/connecting-to-your-database): get connection strings for the restored database.
- [Delete Protection](/console/delete-protection): stop the original database from being deleted by mistake.
3 changes: 2 additions & 1 deletion apps/docs/content/docs/postgres/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ Each Prisma Postgres database includes the following, with no extra services to

- **Connection pooling**: a dedicated PgBouncer instance runs alongside your database, with nothing to set up or manage. It also works for serverless and edge deployments. See [Connection pooling](/postgres/database/connection-pooling).
- **Edge and serverless support**: connect from Cloudflare Workers, Vercel Functions on the Edge runtime, and other edge runtimes via the [serverless driver](/postgres/database/serverless-driver), which uses HTTP instead of TCP.
- **Automated backups** (Starter, Pro, and Business plans): daily snapshots, taken only on days the database has activity, kept for 7 or 30 days depending on the plan. The Console restores one in place, keeping the connection strings, or into a new database; the Prisma CLI and the REST API's restore endpoint restore in place, and the REST API and the MCP server can also restore into a new database. Point-in-time recovery is not available yet. See [Backups](/postgres/database/backups).
- **Automated backups** (Starter, Pro, and Business plans): daily snapshots, taken only on days the database has activity, kept for 7 or 30 days depending on the plan. The Console restores one in place, keeping the connection strings, or into a new database; the Prisma CLI and the REST API's restore endpoint restore in place, and the REST API and the MCP server can also restore into a new database. See [Backups](/postgres/database/backups).
- **Point-in-time recovery (PITR)** (Pro, Business, and Enterprise plans): restore a database to a new database, as it was at a time you choose in the last 7 or 30 days. See [Point-in-time recovery](/postgres/database/point-in-time-recovery).

## Local development

Expand Down
8 changes: 7 additions & 1 deletion apps/site/src/lib/agent-skills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,15 @@ export const MCP_TOOLS: { name: string; description: string }[] = [
name: "list_prisma_postgres_backups",
description: "List available automated backups for a Prisma Postgres database.",
},
{
name: "get_prisma_postgres_pitr_window",
description:
"Get the oldest and newest time a Prisma Postgres database can be restored to with point-in-time recovery. It needs the Pro, Business or Enterprise plan.",
},
{
name: "create_prisma_postgres_recovery",
description: "Restore a Prisma Postgres database to a new database with the given backup id.",
description:
"Restore a Prisma Postgres database into a new database, from a backup id or, with `targetTime`, as it was at a point in time.",
},
{
name: "introspect_database_schema",
Expand Down
Loading