How to do it...

Assuming we have a server that should be archiving transaction logs, follow these steps to store them in a cloud service using WAL-E:

  1. Edit the postgresql.conf file to reflect these parameter settings:
        wal_level = 'replica' 
        archive_mode = 'on' 
        archive_command = 'envdir /etc/wal-e/env wal-e wal-push %p' 
        archive_timeout = '60' 
  1. Restart the PostgreSQL service with the following command as the postgres user:
        pg_ctl -D /db/pgdata restart
  1. Connect as the postgres user and force it to switch transaction logs with this SQL:
        SELECT pg_switch_xlog();
  1. Watch the end of the PostgreSQL log file for transmission success. Use a command similar to this to capture WAL-E specific information:
        tail -f /var/log/postgresql/postgresql-9.6-main.log ...

Get PostgreSQL High Availability Cookbook - Second 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.