This role is for configuring Barman backups on Postgres nodes.
Following are the requirements of this role.
- Ansible
edb_devops.edb_postgres
->setup_repo
role for setting the repository on the systems.
When executing the role via ansible these are the required variables:
- pg_version
Postgres Versions supported are: 10, 11, 12, 13 and 14
- pg_type
Database Engine supported are: PG and EPAS
These and other variables can be assigned in the pre_tasks
definition of the
section: How to include the setup_barman
role in your Playbook
The rest of the variables can be configured and are available in the:
Below is the documentation of the rest of the main variables:
Dedicated Postgres user excuting barman queries. Default: barman
Example:
barman_pg_user: 'barman'
Below are the host variables defined in the inventory file, for each Postgres node we want to backup with Barman.
Enable Barman backups for the host. Default: false
Example:
barman: yes
Barman server private IP address. Default: None
Example:
barman_server_private_ip: 10.0.0.123
Backup method. Can be:
postgres
for backups based onpg_basebackup
using Streaming Replication protocol.rsync
for backups based on thersync
command using SSH protocol.
Default: rsync
Note: rsync
backups can only be proceeded on primary nodes. Backuping
standby nodes must be done with the postgres
backup method.
This role does not have any dependencies, but packages repositories should have
been configured beforehand with the setup_repo
role.
Content of the inventory.yml
file:
---
all:
children:
barmanserver:
hosts:
barman1:
ansible_host: xxx.xxx.xxx.xxx
private_ip: xxx.xxx.xxx.xxx
primary:
hosts:
primary1:
ansible_host: xxx.xxx.xxx.xxx
private_ip: xxx.xxx.xxx.xxx
barman: true
barman_server_private_ip: xxx.xxx.xxx.xxx
barman_backup_method: rsync
standby:
hosts:
standby1:
ansible_host: xxx.xxx.xxx.xxx
private_ip: xxx.xxx.xxx.xxx
upstream_node_private_ip: xxx.xxx.xxx.xxx
replication_type: synchronous
barman: true
barman_server_private_ip: xxx.xxx.xxx.xxx
barman_backup_method: postgres
standby2:
ansible_host: xxx.xxx.xxx.xxx
private_ip: xxx.xxx.xxx.xxx
upstream_node_private_ip: xxx.xxx.xxx.xxx
replication_type: asynchronous
barman: true
barman_server_private_ip: xxx.xxx.xxx.xxx
barman_backup_method: postgres
Below is an example of how to include the setup_barman
role:
---
- hosts: primary, standby
name: Configure Barman backup on Postgres nodes
become: yes
gather_facts: yes
collections:
- edb_devops.edb_postgres
pre_tasks:
- name: Initialize the user defined variables
set_fact:
pg_version: 14
pg_type: "PG"
roles:
- setup_barman
when: "'setup_barman' in lookup('edb_devops.edb_postgres.supported_roles', wantlist=True)"
Defining and adding variables is done in the set_fact
of the pre_tasks
.
All the variables are available at:
This role adds the recovery_options=get-wal
to the barman configuration file,
this implies that the server where a backup is restored is able to access barman
with ssh.
If no ssh access is possible to the Barman server from the new PostgreSQL server
then it is required to execute the recovery with: --no-get-wal
parameter, like:
$ barman recover --no-get-wal \
--remote-ssh-command 'ssh postgresql@restore_server' \
my_server_instance \
latest /path/to/new/pgdata
get-wal
allows to recover partial WAL file from the backup when streaming
backup is used (i.e. the one being currently written by the backuped PostgreSQL
server).
barman recover --no-get-wal
requires recovery_options=get-wal
to be set.
BSD
Author:
- Cédric Villemain
- Julien Tachoires
- Vibhor Kumar (Reviewer)
- EDB Postgres
- [email protected] www.enterprisedb.com