Steps to perform after Restore and Recovery for PostgreSQL cluster deployment
The following procedure is applicable for snapshot, pgbackrest, and pg_basebackup backup methods, and not applicable for the pg_dumpall and pg_dump backup methods.
If the recovery done from backup of PostgreSQL primary node to same or alternate primary node, do the following on the PostgreSQL standby node:
Stop PostgreSQL services.
Clean the PostgreSQL data directory path.
Run the $ pg_basebackup -h primary_node_ip -U db_replication_user --checkpoint=fast -D data_directory_path -R --slot=unique_slot_name -C command with database user.
Start the PostgreSQL services.
If the recovery done from backup of PostgreSQL standby node to same or alternate primary node, do the following on the PostgreSQL primary node:
Stop the PostgreSQL services.
Delete the
standby.signalfile from the data directory.Fix the archive command in
postgresql.conffile from data directory.For example: For Linux: archive_command='cp %p /path/to/archive/location/%f' and for Windows: archive_command = 'copy "%p" "path\\to\\archive\\location\\%f"'
Start the PostgreSQL services.
PostgreSQL standby node:
Stop PostgreSQL services.
Clean the PostgreSQL data directory path.
Run the below command with database user:$ pg_basebackup -h master_node_ip -U db_replication_user --checkpoint=fast -D data_directory_path -R --slot=unique_slot_name -C
Start the PostgreSQL services.
Note:
When the recovery is done from backup of PostgreSQL primary node to PostgreSQL standby node, then the standby node becomes an independent primary node.