Point In Time Recovery with Continuous Archiving

PostgreSQL

Audience
Public
Technology Integrations
Postgre SQL
Source Type
Documentation

This recovery process follows the steps provided in Point In Time Recovery.

To ensure that PostgreSQL recovers the write-ahead-log as apart of the snapshot recovery process ensure the following is in place prior to starting the cluster:

  1. All of the volumes for the PostgreSQL cluster are mounted at the correct locations in the operating system.
  2. The location where archived write-ahead logs are located are readable by the system where the PostgreSQL cluster is being recovered to.
  3. The restore_command entiry in the PostgreSQL configuration file (postgresql.conf) are edited to ensure the files from the write-ahead-log archive can be copied to the PostgreSQL cluster WAL and roll forward the operations which have occurred after the storage snapshot was taken.

    1. restore_command = 'cp /postgres/backups/%f "%p"' 
      
  4. As the PostgreSQL user (In Windows this is the user who owns the PostgreSQL service and in Linux this is postgres) create a recovery.signal file in the data directory. This file informs the cluster that it needs to start in recovery mode.

    1. touch /var/lib/pgsql/13/data/recovery.signal
      
  5. Remove all WAL files in the pg_wal directory.

    1. rm -rf /var/lib/pgsql/13/data/pg_wal/*
      

    At this point the PostgreSQL cluster can be started with will roll forward the write-ahead-log from the archive location.

    More information on continuous archiving and recovery methods can be found in the PostgreSQL documentation.