postgres backup recovery Point‐In‐Time‐Recovery pitr - ghdrako/doc_snipets GitHub Wiki

To do a PITR , you need a full backup and WALs generated to the point of recovery you want. You just have to copy all your archives to some location and create a recovery.conf file in a restored data directory location.

restore_command = 'cp /tmp/demo/archive/%f "%p"'
recovery_target_time = '2019-08-31 15:00:00'

The restore_command specifies how to fetch a WAL file required by PostgreSQL. It is the inverse of archive_command. The recovery_target_time specifies the time until we need the changes.

All available recovery settings are here: www.postgresql.org/docs/11/recovery-target-settings.html. Once the recovery.conf file is ready with the preceding contents, you can start the server using pg_ctl.

pg_ctl -D /restored/data/directory start

If it has to apply archive files on top of backup for recovery, you would see messages like the following in the log file:

LOG:  restored log file "000000010000000300000022" from archiveLOG:  restored log file "000000010000000300000023" from archiveLOG:  restored log file "000000010000000300000024" from archiveOnce recovery is completed, you can see the following messages:
LOG: consistent recovery state reached at 0/40156B0LOG: database system is ready to accept read only connections

You can now use the recovered database.