Skip to content
Stackship documentation Svenska

PostgreSQLUsers

Take and restore snapshots

Take a snapshot of a PostgreSQL cluster, restore it in place, restore to a point in time, and delete snapshots — in the portal or with the CLI.

Requires: postgrescluster/createSnapshot, postgrescluster/restoreSnapshot

Snapshots need backups to be on — see Turn on backups. They are on the cluster's Snapshots tab.

Task Needs Built-in roles
See snapshots and the recovery window postgrescluster/read every role that can see the cluster
Take a snapshot postgrescluster/createSnapshot Owner, Contributor, Databases Operator, Platform Owner, Platform Contributor
Restore or delete a snapshot postgrescluster/restoreSnapshot, postgrescluster/deleteSnapshot Owner, Databases Operator, Platform Owner, Platform Contributor

Take a snapshot

  1. On the Snapshots tab, choose Take snapshot.
  2. Give it a Description, if you like. Keep for has no effect on a PostgreSQL snapshot — see Retention.
  3. Choose Take snapshot. The cluster keeps running; the snapshot is In progress until it is Completed.

A snapshot is refused, with the reason, when backups are off or the cluster reports that archiving is failing. Before the cluster reports that, a snapshot is accepted but stays In progress.

bash
stsh pg snapshot create orders-db --description "before the migration"
stsh pg snapshot list orders-db

Restore a snapshot

  1. Choose Restore on a Completed snapshot.
  2. Restore this snapshot? says what happens: the cluster is recreated from the backup, with a few minutes of downtime; the connection string, the service names and the password stay the same.
  3. Type the cluster's name to confirm, and choose Restore.

Follow the restore on the cluster's Operations tab. Everything written after the snapshot is gone once it completes — see What a restore does. With external access on, the external address can change.

Caution

Prefer a snapshot taken by hand. The restore removes the scheduled snapshots with the old cluster, and a restore of a scheduled snapshot can end with no cluster — see What a restore does.

bash
stsh pg snapshot restore orders-db <snapshot-id>

The CLI asks before it starts, and waits for the restore to finish unless you pass --no-wait.

Restore to a point in time

Once the archive holds a completed snapshot, the tab reads "Snapshots plus a continuous archive since …" and offers Restore to point in time.

  1. Choose Restore to point in time.
  2. Under Restore to, pick the moment, in your browser's time zone. It must lie inside the recovery window: after the time the tab names, and not in the future.
  3. Type the cluster's name to confirm, and choose Restore.

The portal always starts from the newest completed snapshot and replays the archive forward from it, so pick a moment after that snapshot completed. To reach a moment before it, use the CLI and name a snapshot that completed before that moment:

bash
stsh pg snapshot restore orders-db <snapshot-id> --at 2026-09-15T08:30:00Z

--at takes a time such as 2026-09-15T08:30:00Z. A time before the start of the current archive, or in the future, is refused. A time before the named snapshot completed is not refused, but the recovery then fails and the cluster comes back at the newest snapshot of its archive instead — see What a restore does. The same holds for a moment picked in the portal before its newest snapshot completed.

Delete a snapshot

Choose the bin icon on the snapshot, then Delete. The snapshot leaves the list; its data stays in the archive until retention removes it, so deleting one frees no space at once.

bash
stsh pg snapshot delete orders-db <snapshot-id>