observability.svc.plus/roles/pgsql/templates/pgbackrest.conf
2026-02-01 20:53:55 +08:00

99 lines
3.5 KiB
Plaintext

#==============================================================#
# File : pgbackrest.conf
# Desc : PgBackrest Config for {{ pg_instance }} {{ pg_role }}
# Time : {{ '%Y-%m-%d %H:%M' | strftime }}
# Host : {{ pg_instance }} @ {{ inventory_hostname }}:{{ pg_port }}
# Path : /etc/pgbackrest/pgbackrest.conf
# Note : ANSIBLE MANAGED, DO NOT CHANGE!
# License : Apache-2.0 @ https://pigsty.io/docs/about/license/
# Copyright : 2018-2026 Ruohang Feng / Vonng (rh@vonng.com)
#==============================================================#
#--------------------------------------------------------------#
# 1. stanza
#--------------------------------------------------------------#
[{{ pg_cluster }}]
pg1-path={{ pg_data }}
pg1-port={{ pg_port }}
{%if pg_mode|default('pgsql') == 'ivory' %}
archive-header-check=n
pg-version-force={{ pg_version|default(18) }}
{% endif %}
#--------------------------------------------------------------#
# 2. archive
#--------------------------------------------------------------#
[global]
archive-async=y
archive-push-queue-max=4GiB
#--------------------------------------------------------------#
# 3. backup
#--------------------------------------------------------------#
annotation=pg_cluster={{ pg_cluster }}
expire-auto=y
start-fast=y
#archive-copy=n
#--------------------------------------------------------------#
# 4. general
#--------------------------------------------------------------#
compress-type=lz4
spool-path=/pg/spool
#--------------------------------------------------------------#
# 5. log
#--------------------------------------------------------------#
log-path={{ pgbackrest_log_dir }}
log-level-file=info
log-level-console=info
#--------------------------------------------------------------#
# 6. maintainer
#--------------------------------------------------------------#
#--------------------------------------------------------------#
# 7. repository #
#--------------------------------------------------------------#
{% for k,v in pgbackrest_repo[pgbackrest_method].items() %}
repo1-{{ k|replace('_', '-') }}={{ v|replace('${pg_cluster}', pg_cluster) }}
{% endfor %}
#--------------------------------------------------------------#
# 8. restore
#--------------------------------------------------------------#
# archive-mode is intentionally NOT set here
# For disaster recovery (new primary): use default (archive enabled)
# For test/dev restore: add --archive-mode=off on command line
# For exploratory PITR: add --archive-mode=off until correct point found
delta=y
#--------------------------------------------------------------#
# 9. server
#--------------------------------------------------------------#
#tls-server-address=*
#tls-server-port=9638
#tls-server-ca-file=/pg/cert/ca.crt
#tls-server-cert-file=/pg/cert/server.crt
#tls-server-key-file=/pg/cert/server.key
#--------------------------------------------------------------#
# 10. adhoc (parallel)
#--------------------------------------------------------------#
[global:backup]
# 1/4, least 2, max 4
process-max={{ ([ ([ (node_cpu | int / 4) | round(0, 'ceil'), 2 ]) | max, 4 ]) | min | int }}
[global:restore]
# use full cpu, max 8
process-max={{ ([ node_cpu | int, 8 ]) | min | int }}
[global:archive-get]
# 1/4, least 2, max 4
process-max={{ ([ ([ (node_cpu | int / 4) | round(0, 'ceil'), 2 ]) | max, 4 ]) | min | int }}
[global:archive-push]
# async push with 1 / 4
process-max={{ ([ ([ (node_cpu | int / 4) | round(0, 'ceil'), 2 ]) | max, 4 ]) | min | int }}