This page describes how to turn on enable PostgreSQL's WAL file archive feature and how to perform certain workflows, assuming a tDAR infrastructure or development environment.
HOWTO: Configure PostgreSQL for WAL archiving
- Identify/create the associated paths on the postgres server. Unless otherwise stated It is not necessary for these paths to be unique.
- BASEBACKUP - the directory that will hold the "base backup" folder. There should only be one copy of this file at any given time
- XLOG - the directory that holds the archived WAL files
- PGDATA - location of the postgres database directory
- PGCONFIG - location of the postgres configuration files (postgresql.conf, pg_hba.conf, etc.)
- ARCHIVE_SCRIPT - script that postgres executes to process WAL files that are ready to be archived. See separate HOWTO.
- BACKUP_SCRIPT- script that is responsible for pruning the XLOG folder and creating a new creating a new baseline backup in BASEBACKUP. See separate HOWTO
- Configure postgresql.conf. Add / modify the following properties to these values:
- wal_level = archive
- archive_mode = on
- archive_command = '/path/to/ARCHIVE_SCRIPT'
- max_wal_senders = 2
- archive_timeout = 3600 # sets minimum WAL creation every 3600s (1 hr) - can be set at your descretion but consider impact on space requirements.
- Enable replication for postgres user
- pg_hba.conf - add separate line for replication connections (examples in the file's comments).
- ALTER USER postgres WITH REPLICATION;
- register BACKUP_SCRIPT to execute daily - via cron, cron.daily, or (whatever you windows people use).
- restart postgres
- pray.
HOWTO: Create a valid "archive command" script
tbd
HOWTO: Create a valid baseline backup script
tbd
HOWTO: Restore a database from WAL archive
tbd
Troubleshooting
tbd
Related articles