PostgreSQL Barman configuration and commands
step 1: Download 2ndquadrant repo file:
goto http://docs.pgbarman.org/release/2.10/#installation-on-redhatcentos-using-rpm-packagesclick 2ndQuadrant Public RPM repository on https://dl.2ndquadrant.com/default/release/site/
and choose version copy repo link and paste for linux os on root user
step 2: barman server: /et/yum.repo.d/
must pgdg repo file, epel repo file and 2ndQuadrant repo fileopen pgdg repo file and add the line for end of version link ---> exclude=barman*
example: [pgdg11]
name=PostgreSQL 11 for RHEL/CentOS $releasever - $basearch
baseurl=http://download.postgresql.org/pub/repos/yum/11/redhat/rhel-$releasever-$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
exclude=barman*
step 3: barman server :
yum install barman (root user)/usr/bin/barman (bin path)
/etc/barman.conf (barman configuration file)
/et/barman.d/ (server configuration path)
step 4: barman server:(make ssh for both machine)
ssh-keygencd .ssh
ssh-copy-id postgres@192.168.1.21
postgres server:
su - postgres
ssh-keygen
cd .ssh
cat id_rsa.pub >> autorized_keys
scp authorized_keys barman@192.168.1.21:/var/lib/barman/.ssh/
step 5: PostgreSQL server: (make base backup settings)
su - postgrescd /usr/pgsql-11/bin/
./createuser -s -P barman
./createuser -P --replication streaming_barman
vi pg_hba.conf
ipv4:
host postgres barman 192.168.1.22/32 trust
replication:
host replication streaming_barman 192.168.1.22/32 trust
vi postgresql.conf
listern_address=*
archive_mode=on
archive_command='cp %p /arch/%f'
wal_level=replica
full_page_writes=on
max_wal_sender=6
wal_keep_segement=500
max_replication_slot=2
log_statement='all'
restart the server
step 6: barman server:(create .pgpass file)
su - barman(var/lib/barman/)touch .pgpass
chmod 600 .pgpass
vi .pgpass
192.168.1.21:*:*:barman:password
192.168.1.21:*:*:streaming_barman:password
step 7: edit barman configuration file:
vi /etc/barman.conf ---> remove the line(;)barman_user = barman
barman_home = /var/lib/barman/backup
minimum_redundancy = 1
retention_policy = REDUNDANCY 2
:wq
step 8: barman server:(server configuration file create pg1.conf)
vi /etc/barman.d/pg1.conf[pg1]
description = "db server 1"
ssh_command = ssh postgres@192.168.1.21
conninfo = host=192.168.1.162 user=barman dbname=postgres port=5432
streaming_conninfo = host=192.168.1.21 user=streaming_barman port=5432
streaming_archiver = on
slot_name = barman
archiver = on
backup_method = rsync
backup_options = concurrent_backup
parallel_jobs = 4
reuse_backup = link
streaming_archiver_name = barman_receive_wal
path_prefix = "/usr/pgsql-11/bin"
chown -R barman:barman pg1.conf
step 9: Run barman tool
su - barmanbarman list-server
barman check pg1
----------------->barman receive-wal --create-slot pg1
vi postgresql.conf
set archive_command = 'cp %p /arch11/%f && rsync -a %p barman@192.168.1.162:/var/lib/barman/backup/pg1/incoming/%f'
how to find barman xlogfilepath--> barman show-server pg1 | grep incoming_wals_directory
check backup server:
barman check pg1
backup server:
barman backup pg1
backup list:
barman list-backup pg1
backup Details:
barman show-backup pg1 backup_id
Restore command:
barman recover --remote-ssh-command "ssh postgres@192.168.1.162" pg1 20200206T151256 /var/lib/pgsql/11/tada
Point-in-time-Recovery command:
barman recover --remote-ssh-command "ssh postgres@192.168.1.162" pg1 20200206T151256 --target-time "2020-02-06 15:34:24.842" /var/lib/pgsql/11/tada
Incremental Backup:(only last full backup)
barman backup --reuse-backup=link pg1
Comments
Post a Comment