In the previous recipe, we discussed how pg_basebackup can be used to take a physical backup of the PostgreSQL cluster. We may restore this backup in various situations, such as creating a standby server in replication or recovering a database to a point in time. In this recipe, we shall see the steps required to restore a backup taken using pg_basebackup.
Getting ready
In order to restore a backup taken using pg_basebackup, there should be a new directory that has available storage equivalent to the original data directory. Additionally, the backup should be copied over the network, if required, to the target server where it needs to be restored.
The backup needs to be extracted to the targeted data directory as a Postgres user. So, it is important to have access to the Postgres OS user to perform the restore of the database cluster.
How to do it
The following are the steps involved in restoring a backup to the /pgdata directory and starting...