A standby server continuosly reads WAL files from a directory and applies it to the database. The advantage to this is that, switching to the backup server will be fast since only new WAL files need to be applied before promoting the server to primary role.
1. Create an empty standby.signal file in the data directory. Make sure that it is executed as the postgres user. This file will not be deleted and the server will stay in standby mode until promoted using pg_ctl.
touch /var/lib/postgresql/17/main/standby.signal
2. Set up aws credentials in environment variables
#happywell-backup @ x-act aws credentials
export AWS_ACCESS_KEY_ID=AKIAWTVIDJPMGZB6IMLA
export AWS_SECRET_ACCESS_KEY=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
3. Download wal files form s3
aws s3 sync s3://<base backup directory>
4. Find timestamp of newest file
ls .. "*.tgz" -t --full-time | less
5. Untar wal files newer than the last WAL file
TGT_TIME="2026-04-29 11:30:33"
find .. -name "*.tgz" ! -name "main.*" -newermt $TGT_TIME -exec tar -xvzf {} \;
6. Make the database primary and remove standby.signal
pg_ctl promote -D /var/lib/postgresql/17/main