---
title: "Fork a Service and Recover to a Point in Time"
description: "Fork a Managed PostgreSQL service into a new, independent service from its latest state or from a chosen point in time."
url: https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/fork-a-service/
product: "PostgreSQL"
section: product
last_updated: 2026-11-10
---
> For AI agents: the documentation index is at https://community.exoscale.com/llms.txt. Every page is available as markdown at `<page URL>index.md` or with `Accept: text/markdown`.

# Fork a Service and Recover to a Point in Time

Fork a Managed PostgreSQL service to create a new, independent service from the backups of an existing one, either at its latest state or at a chosen moment in the past.

## Forking Is How Point-In-Time Recovery Works

Managed PostgreSQL has no in-place restore: a service is never rolled back on itself. To recover
to an earlier moment, you create a **new service** from the backups of the old one. The source
keeps running, untouched, while the fork is built.

What this means for a recovery:

- The fork has its own hostname. Nothing that points at the source reaches the fork until you
  repoint it.
- Recovering production is *create the fork, verify it, then repoint the application*, or copy
  the rows you need from the fork back into the source. Write that step into your runbook.
- Because the source is never modified, you can rehearse a fork at any time.

## Prerequisites

- The [Exoscale CLI](https://community.exoscale.com/reference/cli/exo/index.md), configured with your API credentials.
- A source service on a `startup-*`, `business-*` or `premium-*` plan. A service on a `hobbyist-*`
  plan cannot be forked: the request fails with
  `Forbidden: Forking is not allowed under the plan`. The fork itself can use any plan, including
  `hobbyist-2`.

## List the Available Backups

```bash
exo dbaas show SERVICE_NAME -z ZONE --backups
```

Parameters:

- `SERVICE_NAME`: name of the source service, for example `my-postgresql`.
- `ZONE`: zone of the source service, for example `ch-gva-2`.

The command prints one row per base backup with a name, a date and a size. Backup names look like
`2026-11-10_13-50_0.00000000.pghoard` and embed the UTC time of the backup. The first backup is
taken while a new service is being created, so a service can be forked as soon as it is `running`.

The same list as JSON, with the fields `backup-name`, `backup-time` and `data-size`:

```bash
exo api get-dbaas-service-pg SERVICE_NAME -z ZONE -q 'backups'
```

You can recover to any moment between the oldest listed backup and now. How many backups a plan
keeps is described in
[Backups and point-in-time recovery](https://community.exoscale.com/product/dbaas/service-specific/postgresql/overview/backups-and-pitr/index.md).

## Fork from the Latest State

```bash
exo dbaas create pg PLAN FORK_NAME -z ZONE \
  --pg-fork-from SOURCE_SERVICE \
  --pg-ip-filter CIDR
```

Parameters:

- `PLAN`: plan of the new service, for example `startup-4`.
- `FORK_NAME`: name of the new service, for example `my-postgresql-fork`.
- `ZONE`: zone in which the fork is created, for example `ch-gva-2`.
- `SOURCE_SERVICE`: name of the service to fork from, for example `my-postgresql`.
- `CIDR`: a network block allowed to connect to the fork, for example `203.0.113.0/24`. Separate
  several blocks with commas.

The fork contains every transaction the source had committed when the fork was requested,
including the writes made after the last base backup. Writes that reach the source after that
moment are not in the fork.

## Fork to a Specific Point in Time

Add `--pg-recovery-backup-time` with the moment you want to land on:

```bash
exo dbaas create pg PLAN FORK_NAME -z ZONE \
  --pg-fork-from SOURCE_SERVICE \
  --pg-recovery-backup-time TIMESTAMP \
  --pg-ip-filter CIDR
```

Parameters:

- `TIMESTAMP`: the moment to recover to, in ISO 8601, for example `2026-11-10T13:53:44Z`. A value
  without a time zone is read as UTC, and fractional seconds are accepted. Unix timestamps and
  relative values such as `yesterday` are rejected.

The fork contains the transactions committed up to that moment and nothing after it. Pick a
timestamp just before the event you are recovering from: if a bad deployment started at 14:32 UTC,
target 14:31.

The API accepts a moment between the oldest backup and the last write on the source. Outside that
range the request fails before anything is created:

- Too early: `recovery_target_time ... beyond our range, oldest available backup from
  2026-11-10 13:50:54.737753+00:00`.
- In the future: `recovery_target_time ... beyond our range, last database write was at ...`.

> [!WARNING]
> Do not reuse a `backup-time` value from the backup list as the recovery target. It is truncated
> to whole seconds while the backup carries sub-second precision, so the value falls just before
> the oldest restorable moment and the request is rejected. Use a moment at least one second
> later.

The same fork through the API:

```bash
exo api create-dbaas-service-pg FORK_NAME -z ZONE <<EOF
{
  "plan": "PLAN",
  "ip-filter": ["CIDR"],
  "fork-from-service": "SOURCE_SERVICE",
  "recovery-backup-time": "TIMESTAMP"
}
EOF
```

Omit `recovery-backup-time` to fork from the latest state.

## Fork into Another Zone

The fork is created in the zone you pass with `-z`, which can differ from the zone of the source:

```bash
exo dbaas create pg PLAN FORK_NAME -z TARGET_ZONE \
  --pg-fork-from SOURCE_SERVICE \
  --pg-ip-filter CIDR
```

Parameters:

- `TARGET_ZONE`: the zone that receives the copy, for example `de-fra-1`.
- `PLAN`, `FORK_NAME`, `SOURCE_SERVICE`, `CIDR`: as above. `SOURCE_SERVICE` is the name of the
  service in its own zone.

This is how a service moves to another zone: stop writes on the source, fork it into the target
zone, verify the fork, repoint the application, then delete the source.

To keep a continuously updated copy in a second zone instead of a one-time copy, use a
[read replica](https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/use-read-replicas/index.md).

## Watch the Fork Come Up

```bash
exo dbaas show FORK_NAME -z ZONE
```

The state moves from `rebuilding` to `running`. A small service takes a few minutes; a large one
takes as long as its backup and WAL take to restore.

## What the Fork Inherits

The fork starts from a physical copy of the source, so everything stored in the database cluster
comes with it. Settings stored on the service are also copied. Some service properties are not.

| Copied to the fork | Not copied |
| --- | --- |
| Databases, tables, data, extensions, publications | IP filter: the fork has only the blocks you pass at creation, and none if you pass none |
| All roles, including those created in SQL, with their passwords | Maintenance window: the fork gets its own |
| The `avnadmin` password: the fork's URI uses the same password as the source | Hostname: the fork has its own |
| Service settings (`pg-settings` and the others) |  |
| Connection pools |  |
| Role and database settings set with `ALTER ROLE` / `ALTER DATABASE` |  |

> [!IMPORTANT]
> A fork created without `--pg-ip-filter` has an empty IP filter and accepts no connection until
> you set one. It holds a full copy of the source's data and the same credentials, so give it a
> filter as narrow as the source's.

## Verify the Fork Before You Cut Over

Read the connection URI of the fork:

```bash
exo dbaas show FORK_NAME -z ZONE --uri
```

Then check:

- **Connectivity.** The IP filter allows the clients that need the fork. Setting the filter
  replaces the whole list, see
  [Restrict connections](https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/restrict-connections/index.md).
- **Data.** Connect and confirm the fork contains the state you aimed for, especially after a
  point-in-time fork. This is the last cheap moment to notice a wrong target.
- **Integrations.** List them with
  `exo api get-dbaas-service-pg FORK_NAME -z ZONE -q 'integrations'` and create the read
  replicas and other integrations the fork needs.
- **Maintenance window.** Set it to match the source if the fork becomes production, see
  [Apply maintenance updates](https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/apply-maintenance-updates/index.md).

Only then repoint your application at the fork's URI.

## What to Use Forks For

- **Recovering from a destructive change**: a dropped table, a migration that rewrote the wrong
  rows, an `UPDATE` without a `WHERE` clause. Fork to just before the change, then either switch
  to the fork or copy the affected rows back into the source.
- **A staging copy with real data**: a fork puts no load on the source. It holds production data,
  so protect it like production.
- **Rehearsing a risky operation**: a schema migration, a bulk fix or a
  [major version upgrade](https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/upgrade-major-version/index.md)
  can be tried on a fork at full data volume, which also tells you how long it takes.
- **Moving a service to another zone**: see [Fork into another zone](#fork-into-another-zone).

## Delete a Fork When You Are Done

A fork is billed like any other service. Termination protection is on by default for services
created with `exo dbaas create`, so turn it off before deleting:

```bash
exo dbaas update FORK_NAME -z ZONE -f --termination-protection=false
exo dbaas delete FORK_NAME -z ZONE -f
```

## Related Pages

- [Backups and point-in-time recovery](https://community.exoscale.com/product/dbaas/service-specific/postgresql/overview/backups-and-pitr/index.md)
- [Plan for disaster recovery](https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/plan-disaster-recovery/index.md)
- [Use read replicas](https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/use-read-replicas/index.md)
- [Manage Backups and Restores](https://community.exoscale.com/product/dbaas/how-to/backups-restore/index.md)

