How to do it...

The following steps assume that a number of environment variables have been set, which are as follows:

  • $PGDATA is the path to the PostgreSQL data directory, ending with /
  • All required PostgreSQL connection parameters have been set
The initial procedure is step 1 onwards. If you are running subsequent backups, start from step 3.

The steps are as follows:

  1. Create a new backup directory, if it is not already present, as follows:
        cd $PGDATA        mkdir ../standalone
  1. Set an archive_command. In postgresql.conf you will need to add the following lines and restart the server, or just confirm that they are present:
        archive_mode = on        archive_command = 'test ! -f ../standalone/archiving_active || cp -i %p ../standalone/archive/%f' ...

Get PostgreSQL Administration Cookbook, 9.5/9.6 Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.