Configuring the PostgreSQL Archive Log Directory

The Archive log files are stored in the Archive Log directory.

Note

  • The archive log directory must be outside the data directory.

  • The archive log directory must be on a drive or volume with sufficient free space.

  • Make sure that this path does not point to pg_log or log directories and pg_xlog or pg_wal directories.

Ensure to follow the below checkpoints before running the PostgreSQL FS backup:

Procedure

  • Specify the Archive log directory path in the postgresql.conf file prior to performing the PostgreSQL FS backup.

    archive_command = 'cp %p /opt/wal/%f' #UNIX
    archive_command = 'copy "%p" "D:\\PostgreSQL\\wal\\%f"' #Windows
  • For PostgreSQL 8.3 version and later, use the following configuration to turn on the archive_mode. This feature is not supported for PostgreSQL 8.2 and earlier versions.

    archive_mode = on
  • The archive_mode cannot be enabled when wal_level is set to minimal. Configure it based on the replication type for your instance.

    For a standalone instance, you may set it to archive or replica as applicable for your PostgreSQL version.

    For more information, refer PostgreSQL Documentation, Write Ahead Log.

  • Verify that the archive command provided in the postgresql.conf file is correct. You can test this by running the following commands and verifying that they successfully complete.

    For PostgreSQL 15 and more recent versions:

    select pg_backup_start('t', 'f');
    select pg_backup_stop();

    For PostgreSQL versions 9.5 to 14:

    select pg_start_backup(‘test’, 'f', 'f');
    select pg_stop_backup('f');

    For PostgreSQL versions older than 9.5:

    Select pg_start_backup(‘Test’);
    Select pg_stop_backup();

For more information about disk caching, refer to Disk Caching for Frequent Database Log Backups.

Loading...