The primary mechanism that PostgreSQL uses to provide a data durability guarantee is through its Write-Ahead Log (WAL). All transactional data is written to this location before ever being committed to database files. Once WAL files are no longer necessary for crash recovery, PostgreSQL will either delete or archive them. For a highly available server, we recommend that you keep these important files as long as possible. There are several reasons for this:
- Archived WAL files can be used for Point-In-Time Recovery (PITR).
- If you are using streaming replication, interrupted streams can be re-established by applying WAL files until the replica has caught up.
- WAL files can be reused to service multiple server copies.
To gain these benefits, we need to enable PostgreSQL WAL archiving and save these files until we no longer need them. This recipe will address...