This is an old revision of the document!
Overview
I find pgbackrest, way more “stupid” (or maybe I am “stupid) than Barman. I am sorry, but I guess I just don't get it.
You have a pgbackrest executable, which checks the config file, it generates the postgresql.auto.conf file and the server STILL restores till the last WAL files when you try to do PITR. But I guess I will return to this section, when I am smarter and know how to use it.
Either case, let's get into it. Unlike Barman, pgbackrest REQUIRES passwordless connection for the backup / restore to the server and unlike Barman in REQUIRES you to archive the WAL Files to a common repo or global repo. P.S. Barman doesn't require passwordless connection for backup, as we can configure “streaming” server….
Either case, so in general. My setup is. 1 central backup server, 1 NFS on that backup server, which is mounted on the data nodes and the data nodes push the WAL Files to that repo using pgbackrest. Simple as that.
Setup
After you install pgbackrest on all servers: data nodes + backup server. You can set the archive command as follows:
Setup archive & restore commands
archive_command: "pgbackrest --stanza=cluster_backup archive-push %p" restore_command: "pgbackrest --stanza=cluster_backup archive-get %f %p"
So in nutshell, my patroni.yml looks like this:
Patroni Yaml
scope: stampede name: ${host} restapi: listen: ${host}:8008 connect_address: ${host}:8008 etcd: hosts: etcd00:2379, etcd01:2379, etcd02:2379 bootstrap: dcs: ttl: 30 loop_wait: 10 retry_timeout: 10 maximum_lag_on_failover: 1048576 maximum_lag_on_syncnode: 15000000 synchronous_mode: true postgresql: use_pg_rewind: true use_slots: true initdb: - encoding: UTF8 - data-checksums pg_hba: - host replication rep_user ${subnet}.0/24 md5 - host all all ${subnet}.0/24 md5 postgresql: listen: ${host}:5432 connect_address: ${host}:5432 data_dir: /db/pgdata bin_dir: ${bindir} pgpass: /tmp/pgpass0 authentication: replication: username: rep_user password: newpass superuser: username: postgres password: newpass parameters: unix_socket_directories: '/var/run/postgresql' external_pid_file: '/var/run/postgresql/17-main.pid' logging_collector: "on" log_directory: "/var/log/postgresql" log_filename: "postgresql-17-main.log" shared_buffers: 100MB work_mem: 16MB maintenance_work_mem: 10MB max_worker_processes: 16 wal_buffers: 16MB max_wal_size: 200MB min_wal_size: 100MB effective_cache_size: 50MB fsync: on checkpoint_completion_target: 0.9 log_rotation_size: 100MB listen_addresses: '*' max_connections: 2000 temp_buffers: 4MB archive_mode: "on" wal_level: "replica" archive_command: "pgbackrest --stanza=cluster_backup archive-push %p" restore_command: "pgbackrest --stanza=cluster_backup archive-get %f %p"
After that, we need to create the Stanza (Configuration of server and a backup). That is done from the backup server.
Create Stanza
Create Stanza
pgbackrest --stanza=cluster_backup stanza-create
That command will create you the stanza and then the archive command from the data nodes will work. You can also manually archive a file as follows, ran from the data node.
Manually archive a file
pgbackrest --stanza=cluster_backup archive-push /db/pgdata/pg_wal/000000010000000000000001 --log-level-console=debug