Restoring a PostgreSQL cluster
Last updated: 6 November 2026
Every PostgreSQL cluster with backups archives its changes continuously (at least every five minutes, or every minute if you choose) and takes regular base backups. There are two independent ways back from them: through the BasePilot console, also onto another provider or location, and without BasePilot at all, from a bucket of your own with the cluster's recovery kit.
Prepare before you need it
- Backups in a bucket of your own. Under Organization settings › Backup storage, connect an S3-compatible bucket and choose it for the cluster (when creating it, or later on its Backups page). Create the bucket with S3 Object Lock in compliance mode and give BasePilot a key that may only upload, read and list: then nobody with access to BasePilot, and not even your own account, can delete backups before their retention ends. The console shows the result of its check on every bucket.
- A read-only key for that bucket, kept by you and not given to BasePilot.
- The recovery kit of each cluster (Backups › Recovery kit), stored in your password manager or vault. It contains the key that decrypts the backups. A cluster that was restored or upgraded to a new major version is a new cluster with its own kit.
- A machine with Docker for a restore without BasePilot: a laptop for a test, a server in the region you need for production.
- A practice run of both ways every few months, with the time each one took noted down.
Way 1: restore through BasePilot
For when a server, a location or a whole hosting provider is unavailable, or data was damaged and you need it as it was at an earlier time, while BasePilot itself works.
- In the console, open Clusters › Restore from backup (or the Backups page of the cluster).
- Choose a base backup, or enter a point in time under “Restore to a point in time”.
- In the dialog, leave “Size and provider” as it is, or pick a plan of another provider and a location when the original one is not available. Choose where the new cluster keeps its backups.
- The new cluster starts from the backup and replays the archived changes up to the end or to the chosen time. The original cluster stays untouched.
- The restored cluster has its own address. Application users keep their passwords, so the application only needs the new host name (connection details are on the cluster overview). Check the data, move the traffic, and delete the old cluster when it is no longer needed.
How long it takes depends on the size of the database: a new server, the download of the base backup and the replay of the changes since then.
Way 2: restore without BasePilot
For when BasePilot or your account is not reachable. You need the recovery kit, the read-only key and a machine with Docker; nothing from BasePilot or the hosting provider.
export BACKUP_ACCESS_KEY_ID=... # the read-only key of your bucket
export BACKUP_SECRET_ACCESS_KEY=...
bash shop-ab12c-recovery.sh list # base backups and when they finished
bash shop-ab12c-recovery.sh restore # newest backup plus every archived change
bash shop-ab12c-recovery.sh restore --target-time "2026-11-06 09:30:00+01" # a point in timeThe kit downloads WAL-G (the tool the clusters back up with; its checksum is pinned in the kit), fetches a base backup into a Docker volume, replays the archived changes and starts the official PostgreSQL image of the cluster's major version on 127.0.0.1:5432. For a point in time it starts from the newest base backup that finished before that time and refuses times before the oldest one, because a recovery can never stop before the end of its base backup.
- Roles, passwords, databases, row-level security policies, grants and functions are exactly as they were: the restore is a physical copy.
- The kit prints how to set a new password for the admin role. To serve applications, run the kit on a server and publish the port behind your firewall and TLS, or copy the data with
pg_dumpinto any PostgreSQL of the same or a newer major version. - Options:
--port,--name(container and volume),--backup(a base backup fromlist).BACKUP_S3_ENDPOINT,BACKUP_S3_BUCKETandBACKUP_S3_PREFIXpoint the kit at a copy of the backups elsewhere.
In our tests the restore of a small database took about ten seconds after the download; larger databases take as long as downloading their base backup and replaying the changes since.
When objects in the bucket were overwritten
The key BasePilot holds cannot delete, but it can upload. If someone with that key (or with your own account) replaced backup objects, Object Lock keeps the earlier versions until their retention ends. Copy the versions from before the incident into a new bucket or prefix with your provider's tools (for example aws s3api list-object-versions and get-object --version-idon AWS), then run the kit with BACKUP_S3_BUCKET and BACKUP_S3_PREFIX set to that copy.
Help
Write to hi@basepilot.de or use the support chat in the console. We help with restores and the switch-over; the steps above work without us.