restore_command
restore_command
is a configuration parameter defining the command to retrieve an archived WAL file.
restore_command
was added in PostgreSQL 8.0.
In PostgreSQL 11 and earlier, restore_command
was a replication configuration command which could only be set in recovery.conf.
Default value
The default value for restore_command
is: ''
(empty string).
Change history
- PostgreSQL 14
- can now be changed with a configuration reload (
SIGHUP
) rather than a server restart (commit 942305a3)
- can now be changed with a configuration reload (
- PostgreSQL 12
- PostgreSQL 8.0
- added (commit 66ec2db7)
Examples
Using the following restore_command
as an example:
scp backupuser@backup:/var/lib/backup/wal-archive/%f "%p"
In normal operation, the PostgreSQL log file will contain entries like the following when retrieving archived WAL:
[2021-06-20 10:14:16 UTC] LOG: 00000: restored log file "000000010000000000000004" from archive [2021-06-20 10:14:17 UTC] LOG: 00000: restored log file "000000010000000000000005" from archive [2021-06-20 10:14:17 UTC] LOG: 00000: restored log file "000000010000000000000006" from archive
The log file will also contain entries like the following:
scp: /var/lib/backup/wal-archive/000000010000000000000007: No such file or directory scp: /var/lib/backup/wal-archive/00000002.history: No such file or directory
These are not errors. PostgreSQL will continuously attempt to retrieve the next expected WAL file, and the next history file in case the upstream has been promoted to a new timeline. If the files are not (yet) present, the configured command (here scp
) will report a file-not-found error, which is expected and normal.
References
- PostgreSQL documentation: restore_command
- PostgreSQL 11 documentation: restore_command