Office docsRun it
Point-in-time recovery
With continuous archiving on, a restore can stop at a chosen moment. Without it, which is the default, anything written since the last backup is lost.
Point-in-time recovery has not yet run on any installation. Watch your first use closely and keep taking ordinary backups.
Before you turn it on
- A working object-store destination. Set up Back up and restore and take one successful backup first. A filesystem destination cannot be used.
- Disk space for the spool, where segments wait until they are uploaded. A few gigabytes covers the backlog of one outage.
- A decision before the first install. The backup profile is written into the installation when it is created, so turning this on later means a fresh installation and a restore.
Turn it on
Continuous archiving is configured by compose.continuous.yaml, which sets KW_BACKUP_CONTINUOUS=1. That setting is read only at first install. With every KW_BACKUP_S3_* setting already in place, start the installation with both files.
$ docker compose -p kernalworks-office -f compose.yaml -f compose.continuous.yaml up -d
Use both -f files for every later command, including restart, stop and logs. A command with only compose.yaml recreates the database without archiving. Nothing is corrupted, but point-in-time recovery stops without warning. A shell alias helps.
At startup, the log shows the archiving destination and the scheduled jobs.
backup to <bucket> at <endpoint> with continuous WAL archiving
scheduled jobs: backup retention-prune disk-pressure wal-archive
wal-archive in the job list confirms archiving is on. If it is missing, the installation was created with a snapshot profile, and restarting will not change that.
How segments are archived
PostgreSQL copies each finished WAL segment into a spool directory. The installation encrypts it under your backup key, uploads it without overwriting, reads it back to compare, and records it in a local chain so a gap can be detected. The spool file is deleted only after all of that, so a crash costs a re-upload, not a segment.
Watch the spool
PostgreSQL reports healthy as soon as a segment reaches the spool. If the object store becomes unavailable, the database stays healthy while your recovery point falls behind. Two signals catch this.
- The
wal-archivejob raisesarchive-lagwhen the backlog exceeds 64 segments. /health/statusreportscriticalwhen the newest archived segment is older than three timesarchiveTimeoutSeconds, or when nothing has been archived on an installation that has taken a backup.
Neither takes the installation out of service.
Recover to a moment
Recovery lays a base backup into an empty data directory and lets PostgreSQL replay the WAL. To stop at a chosen moment, set recovery_target_time in the recovery configuration. The rest is the same as restoring a continuous backup.
A continuous backup cannot cross a major PostgreSQL version. To recover onto a different major version, use a snapshot backup.
What you manage yourself
| Task | Why it is manual |
|---|---|
| Turning it on | Archiving makes PostgreSQL keep WAL until each upload succeeds. A spool nobody drains fills the disk. |
| Pruning the archive | WAL segments are pruned by count with retainWalSegments. Use your bucket's lifecycle policy for the rest. |
| Verifying a recovery | Only recovering an archive proves it can be recovered. |