Overview

Write ahead log or WAL is analog of many other databases transactional logs:

Oracle - Archive log

DB2 - Transactional Log

Microsoft - Transactional Log

and so on.

The basic idea is to keep little files with information about our changes. In postgreSQL we have 3 levels of WAL settings:

Minimal

Replica

Logical

If you depend on WAL for recovery, REPLICA is good option.

Enabling

In order to enable WAL, you have edit the postgresql.conf file and change the following settings:

wal_level (replica or logical)

wal_max_senders (should be >= 1)

archive_mode (should be on)

archive_command (depends on your environment but here is an example: 'test ! -f /var/lib/pgsql/9.6/archive/%f && cp %p /var/lib/pgsql/9.6/archive/%f'

Once all is done, we have to restart the service as follows:

Verify

Write Ahead Log (WAL) Enables us to make online base backup, so let's verify if the WAL works firstly:

Seems all is fine, now we can make a base backup, explained further in the wiki.