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.

IT admins8 min

Watch the first use

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.

bash
$ docker compose -p kernalworks-office -f compose.yaml -f compose.continuous.yaml up -d
Pass both files every time

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.

output
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-archive job raises archive-lag when the backlog exceeds 64 segments.
  • /health/status reports critical when the newest archived segment is older than three times archiveTimeoutSeconds, 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

TaskWhy it is manual
Turning it onArchiving makes PostgreSQL keep WAL until each upload succeeds. A spool nobody drains fills the disk.
Pruning the archiveWAL segments are pruned by count with retainWalSegments. Use your bucket's lifecycle policy for the rest.
Verifying a recoveryOnly recovering an archive proves it can be recovered.