Skip to content
Stackship documentation Svenska

PostgreSQLUsers

Turn on backups

Turn backups on for a PostgreSQL cluster, set when its scheduled snapshot runs, and turn them off again.

Requires: postgrescluster/write

Turning backups on or off needs postgrescluster/write; the Owner, Contributor and Databases Operator roles have it. Backups need a backup target, which the platform's operators set up; without one, a cluster with backups on has nowhere to archive to.

When you create the cluster

Turn on Enable Backups in the wizard's Backup step — see Backup.

On an existing cluster

  1. On the cluster's Configuration tab, section Database, go to Monitoring & Backup.
  2. Turn on Enable Backups.
  3. Set the Backup schedule — Daily or Weekly at a time of day in UTC, or a Custom cron expression with five fields, in UTC — and the Backup Retention Policy, such as 30d. What applies today is described in Retention.
  4. Choose Save.

The instances then restart one at a time — a single instance briefly — because the archiving agent runs beside each of them. From then on the write-ahead log is archived continuously.

The first scheduled snapshot is taken at the next scheduled time, not at once, and a point-in-time restore is possible only once the archive holds a snapshot. Take one right away rather than wait — see Take a snapshot.

With the CLI

bash
stsh pg update orders-db --set backupConfigured=true --set backupSchedule="30 1 * * *"

Without a schedule the snapshot runs daily at 03:00 UTC.

Scheduled snapshots

The scheduled snapshots appear on the Snapshots tab next to the ones taken by hand, described as Scheduled by …. They are restored, and deleted, like any other snapshot, but they do not survive a restore of the cluster — see What a restore does.

Turn backups off

Turn off Enable Backups and choose Save, or --set backupConfigured=false. The schedule is removed and the cluster stops archiving; its instances restart again. The snapshots already taken stay in the list, but while backups are off none can be taken or restored.