# Postgres point-in-time restore: undo a migration

Source: https://resilis.io/guides/postgres-point-in-time-restore/

Updated date: 2026-11-19

It is 14:32. A migration that looked fine in review has dropped a column in production. Orders are still coming in. The nightly backup is twelve hours old, and restoring it would erase a morning of real work. This is what point-in-time restore is for. With continuous backups on, a Resilis PostgreSQL database can be restored to a chosen minute inside its retention window. In this case, that minute is 14:31, before the migration ran. Point-in-time restore is included on the Pro and Enterprise plans. Hobby includes snapshots.

## Why app rollback is not enough

Rolling back the app is usually the first instinct, and it is still a good first step. It puts the previous code back in front of users. It does not touch the database. The column is still gone, and the data in it is still gone.

Code and data have separate undo buttons:

### Why app rollback is not enough

| Problem | Undo with |
| --- | --- |
| A release has a bug | App rollback to the previous deployment |
| A migration damaged data or schema | Database restore: snapshot or point-in-time |
| Both | Roll back the app first, then restore the database |

## Before you need it: turn on continuous backups

Point-in-time restore depends on continuous backups. They must be on before the incident; a restore cannot reach back to a time before archiving started.

When you create a PostgreSQL database, or later from its settings, turn on Continuous backups and choose a retention window. The dashboard offers 3, 7, 14, 30, 60 or 90 days. The retention window decides how far back a restore can reach. Over MCP, agents can set retention between 1 and 365 days.

On Hobby, the toggle is disabled with an upgrade prompt. Hobby databases can still use snapshots.

## The recovery, step by step

## 1. Write down the time

Find the moment the migration started. Your migration tool's log, the deploy history and the release command logs all carry timestamps. Pick a restore target one minute before it: here, 14:31.

Note the time zone. The dashboard's time picker uses your browser's local time and converts it to UTC when you submit. If your logs are in UTC, convert the time before you enter it. Over MCP, the restore time is an RFC3339 timestamp, so include the offset.

## 2. Stop the damage

Roll back the app to the deployment before the migration, from the app's deployment history or with your agent. This keeps the broken code from writing more data into the broken schema.

If you need to stop the app entirely, remember that stopping a production resource asks an account owner to approve by email. Plan for that during an incident: know who your owners are.

## 3. Check what can be recovered

Open the database and go to Backups. The Restore calendar marks days with snapshots in green and point-in-time coverage in blue. Select today and check that the coverage window includes 14:31.

From an agent, databases.backups.availability returns the same snapshot days and point-in-time coverage, and databases.backups.status reports backup health and restore readiness.

## 4. Restore into a new database first

Choose Point-in-time as the recovery mode and enter 14:31. Always enter a time: without one, the restore replays to the latest point, which includes the bad migration. For the target, choose Restore to new database, then Fork. The form starts on Restore in place, so change it before you submit.

A fork leaves the current database untouched and builds a second one as it was at 14:31. That gives you room to check before you replace anything:

### SQL

```sql
-- On the fork: is the dropped column back, with data?
SELECT count(*) FROM orders WHERE delivery_notes IS NOT NULL;

-- What arrived after 14:31 in production that the fork won't have?
SELECT id, created_at FROM orders WHERE created_at >= '2026-11-19 14:31:00+00';
```

Over MCP, the same request is databases.restore with source_type: "wal", an RFC3339 restore_time, and target_mode: "fork".

## 5. Choose how to switch

Now you know what the fork contains and what production gained after 14:31. There are two ways forward:

- Restore in place. Choose Restore in place with the same point in time. The production database returns to its 14:31 state and is temporarily unavailable while the restore runs. Anything written after 14:31 is replaced, so export those rows first if you need them. Over MCP, an in-place restore requires an explicit confirm_inplace: true.
- Copy back from the fork. If only one column or table was damaged and production has valuable new writes, copy the lost data from the fork into production with SQL, and keep the current database.

For a dropped column with steady traffic, copying back is often the smaller change. For widespread damage, restoring in place is cleaner.

## 6. Fix the migration and verify

Correct the migration so it is safe to run again: add the new column, backfill, and only remove the old one in a later release. Test it against a development or staging copy first.

Then check the app end to end. Read records written before 14:31. Create a new one. The restore is done when the application behaves correctly, not when the job turns green.

## Rehearse it once

A restore you have never run is a hope, not a plan. Rehearse on a staging database with disposable data:

- 1. Turn on continuous backups on staging.
- 2. Insert a few marked rows, wait a minute, note the time, then drop a column.
- 3. Fork-restore to the noted minute and check the rows are back.
- 4. Delete the fork when you're done. Staging resources can be deleted directly.

Note how long each step took. That number is your own evidence for "how fast can we recover?", which no platform can promise for you.

## What point-in-time restore does not promise

- It does not reverse code. Pair it with app rollback.
- It cannot reach before continuous backups were turned on, or past the retention window.
- It does not come with a guaranteed recovery time or recovery point. Available archives decide which minutes are recoverable.
- Keep independent copies of data you cannot afford to lose.

## Frequently asked questions

Can I restore a Postgres database to a specific minute? Yes, on Pro and Enterprise with continuous backups on. Choose Point-in-time in the database's Backups tab and enter the time, within the retention window shown.

Does rolling back my app undo a database migration? No. App rollback restores code only. Use a snapshot or point-in-time restore for the database.

Will a restore overwrite my current data? Only if you choose Restore in place. Restore to new database creates a fork and leaves the current database as it is.

Is point-in-time restore available on the Hobby plan? No. Hobby includes snapshots. Point-in-time restore is part of Pro and Enterprise.

Can my AI agent run the restore? An agent with the right access can request one through databases.restore. An in-place restore requires an explicit confirmation flag. Review the target time and mode before you approve the request in your agent.
