After restoring the application data and logs, you can recover the PostgreSQL database from the disk using PostgreSQL restore commands.
Procedure
-
For PostgreSQL version 11 or earlier, on the destination server, under the PostgreSQL Data directory, create a recovery.conf file.
For PostgreSQL versions 12 and later, on the destination server, under the PostgreSQL Data directory, create an empty file named recovery.signal.
-
Add the following restore commands to the recovery.conf file for PostgreSQL version 11 or earlier, and to the postgresql.conf file for PostgreSQL versions 12 and later:
For a UNIX server, enter the following:
restore_command = 'cp TARGET_RESTORE_DIR/%f "%p"'For example, enter the following:
restore_command = 'cp /opt/PostgreSQL/9.6/restore_to_disk/9011/opt/PostgreSQL/9.6/wal/%f "%p"'For a Windows server, enter the following:
restore_command = 'copy "TARGET_RESTORE_DIR\\%f" "%p"'For example, enter the following:
restore_command = 'copy "C:\\PostgreSQL\\restore_to_disk\\9014\\PostgreSQL\\wal\\%f" "%p"' -
For non-exclusive backups in PostgreSQL versions 9.5 and above, copy the backup_label file from archive log directory to the data directory.
For example, enter the following:
cp /opt/PostgreSQL/9.6/restore_to_disk/9011/opt/PostgreSQL/9.6/wal/backup_label /opt/PostgreSQL/9.6/restore_to_disk/9011/opt/PostgreSQL/9.6/data -
Start the PostgreSQL server.
-
After the PostgreSQL server is online, remove the recovery related parameters from the postgresql.conf file.