PostgreSQL records every change made to the database’s data files into a write ahead log (WAL) file
that is available in the pg_wal/ subdirectory of the cluster’s data directory. This log is intended primarily
for a crash recovery. After a crash, the log entries made since the last checkpoint can be used for
restoring the database to a consistency.
The continuous archiving method, also known as an online backup, combines the WAL files with a copy
of the database cluster in the form of a base backup performed on a running server or a file system level
backup.
If a database recovery is needed, you can restore the database from the copy of the database cluster
and then replay log from the backed up WAL files to bring the system to the current state.
With the continuous archiving method, you must keep a continuous sequence of all archived WAL files
that extends at minimum back to the start time of your last base backup. Therefore the ideal frequency
of base backups depends on:
The storage volume available for archived WAL files.
The maximum possible duration of data recovery in situations when recovery is necessary. In
cases with a long period since the last backup, the system replays more WAL segments, and the
recovery therefore takes more time.
NOTE
You cannot use pg_dump and pg_dumpall SQL dumps as a part of a continuous
archiving backup solution. SQL dumps produce logical backups and do not contain
enough information to be used by a WAL replay.
To perform a database backup and restore using the continuous archiving method, follow these
instructions:
1. Set up and test your procedure for archiving WAL files - see WAL archiving.
2. Perform a base backup - see base backup.
To restore your data, follow instructions in Restoring database with continuous archiving.
4.5.3.2. Advantages and disadvantages of continuous archiving
Continuous archiving has the following advantages compared to other PostgreSQL backup methods:
With the continuous backup method, it is possible to use a base backup that is not entirely
consistent because any internal inconsistency in the backup is corrected by the log replay.
Therefore you can perform a base backup on a running PostgreSQL server.
A file system snapshot is not needed; tar or a similar archiving utility is sufficient.
Continuous backup can be achieved by continuing to archive the WAL files because the
sequence of WAL files for the log replay can be indefinitely long. This is particularly valuable for
large databases.
Continuous backup supports point-in-time recovery. It is not necessary to replay the WAL
entries to the end. The replay can be stopped at any point and the database can be restored to
its state at any time since the base backup was taken.
If the series of WAL files are continuously available to another machine that has been loaded