Skip to content

Backups

Every piece of cluster state—users, projects, threads, machines, the workspace catalog, and stored secrets—lives in Postgres. Anastro backs up Postgres using WAL-G: continuous WAL archiving plus scheduled base backups encrypted on the node before upload. Workspace files already live in your workspaces store and aren’t duplicated here.

Add [backup] to anastro.toml, pointing at a dedicated [storage.backups] bucket:

[backup]
enabled = true
store = "backups"
[backup.policy]
base_backup = "daily 03:15" # UTC, or "weekly sun 03:15"
retain_full = 7 # number of full base backups to keep
pitr_window = "7d" # must be <= filesystem.gc.delete_after
encryption_key = "secret:backup/encryption_key"
[backup.verify]
enabled = true
schedule = "weekly sun 05:00" # UTC

Generate the 32-byte hex encryption key, unseal, test the bucket, apply, and take your first base backup:

Terminal window
openssl rand -hex 32 | anastroctl cluster bundle set backup/encryption_key
anastroctl cluster unseal
anastroctl cluster storage test backups
anastroctl cluster apply
anastroctl cluster backup now

backup.* and storage.* apply live without restarts. Take an immediate base backup right after enabling—point-in-time recovery only starts from the first base backup.

Clusters with backups disabled raise BackupsDisabled. On a single-node cluster, losing the disk without backups means losing everything.

  • The Postgres primary archives WAL continuously and takes base backups on schedule; if Patroni fails over, the new primary takes over automatically.
  • After each successful base backup, backups older than retain_full are pruned.
  • A node refuses to write base backups into a bucket that already belongs to a different database, protecting older cluster backups from accidental overwrite.
Terminal window
anastroctl cluster backup status # list base backups and primary WAL archiving status
anastroctl cluster backup now # trigger a base backup immediately

Alerts: BaseBackupMissed (no backup yet, or overdue by an hour) and WalArchiveStalled (WAL archiving failing for 5 minutes).

When [backup.verify] enabled = true, a node (the first replica by name, or the primary on a single-node cluster) periodically restores the latest base backup and WAL into a scratch Postgres instance, runs amcheck on tables and indexes, checks that row counts match the live database within 10% (or 100 rows), confirms the newest event is recent, and tears down the scratch instance.

Run a verification manually anytime:

Terminal window
anastroctl cluster backup verify
anastroctl cluster backup verify -n cp3

Any failure raises BackupVerifyFailed until a subsequent verification succeeds.

Terminal window
anastroctl cluster backup restore -n cp1 --target-time 2026-11-02T13:55:00Z
anastroctl cluster backup restore -n cp1 # restore to the latest archived WAL

This replaces the cluster’s database with the newest base backup prior to --target-time plus WAL up to that moment. In HA clusters, other nodes pause while cp1 restores and then re-clone from cp1. If the restore fails, every node rolls back to its previous database. Restoring opens a new Postgres timeline so earlier and later restore points remain reachable, and targeting a time before a Postgres major upgrade restores that older major version automatically.

Rewinding Postgres does not delete objects uploaded to the workspaces store after --target-time. After a restore, Anastro revokes active workspace leases so hosts re-acquire cleanly, pauses garbage collection until a reindex scans objects uploaded after the target time, and marks newer snapshots orphaned (kept and adoptable for orphan_retention):

Terminal window
anastroctl cluster fs status
anastroctl cluster fs reindex --since 2026-11-02T13:55:00Z

If you lose every node, install replacement nodes from the same config repo (with [backup] enabled = true) and restore during bootstrap:

Terminal window
anastroctl cluster bootstrap --restore-from backups
anastroctl cluster bootstrap --restore-from backups --target-time 2026-11-02T13:55:00Z -n cp2

See Lose every node for the full runbook.

Upgrades.