I am trying to perform a Point-In-Time Recovery using the WAL_ARCHIVE process. The archive command is added to the postgresql.conf file and I can see the WAL being archived in the backup-archive directory. When I try to start the service I get PANIC: could not locate a valid checkpoint record
I am using the below step-by-step process.
- low level api basebackup
SELECT pg_start_backup('label', true, false);
- copying the data directory of my cluster
tar -zcvpf basebkPostgres20230110New.tgz /PostgreSQL/13/data
- closing my basebackup
SELECT * FROM pg_stop_backup(false, true);
- Stopping the postgres service
- Removing the current's cluster data directory
- Restoring the backed up data directory
- Removing the contents of the pg_wal directory
- Setting the restore_command in the postgresql.conf file
- Starting the postgres service
You forgot the
backup_label
file andrecovery.signal
. You have to capture the result ofpg_stop_backup
(orpg_backup_stop
from v15 on) and createbackup_label
from the contents. That file has to be in the restored data directory. Also, you have to createrecovery.signal
in the data directory, so that PostgreSQL starts in archive recovery mode and reads yourrestore_command
.Without
restore_command
, PostgreSQL uses the WAL inpg_wal
, which is empty. Withoutbackup_label
, PostgreSQL thinks that it can recover from the checkpoint indicated by the control filepg_control
. Even if that worked, the result would be a corrupted database, since you have to recover from the start of the backup.recovery.signal
is documented here (step 7), andbackup_label
is documented here (step 4).