Here again i am trying to explore another backup and recovery tool for PostgreSQL that is BARMAN Earlier i have tried PgBackRest
Where pg-remote is server name .
Below image shows some of the ,Examples .
Now we will take a backup for one server .
List out the backups ,By using below commands .
Now,Lets restore some backup of remote host .
So ,Lets start with the BARMAN .
Below is features of BARMAN .
- Full hot physical backup of a PostgreSQL server
- Point-In-Time-Recovery (PITR)
- Management of multiple PostgreSQL servers
- Remote backup of a PostgreSQL server
- Remote recovery of a backup for a PostgreSQL server
- Management of base backups and WAL files through a catalog
- ssh support for remote operations
- rsync over ssh support for file synchronisation and transfers
- Management of retention policies for backups and WAL files
- Incremental backup
- WAL hub (get-wal)
- Compression of WAL files (bzip2, gzip or custom)
- Backup general and disk usage information
- Integration with standard archiving tools (e.g. tar)
- Local recovery
- Relocation of PGDATA and tablespaces at recovery time
- Server diagnostics for backup
- Server status and information
- Pre/Post backup hook scripts
- Local storage of metadata
- INI configuration file
- Written in Python
- Control of bandwidth usage
Below are packages should be with you .
- Linux/Unix
- Python 2.6 or 2.7
- Python modules:
- argcomplete
- argh >= 0.21.2 <= 0.26.2
- argparse (Python 2.6 only)
- psycopg2 >= 2.4.2
- python-dateutil <> 2.0
- setuptools
- PostgreSQL >= 8.3
- rsync >= 3.0.4 (optional for PostgreSQL >= 9.2)
Note : Password less (SSH) login should be in place between DB server and BARMAN server .
Below are steps to install python and related packages .
Below are the steps to install BARMAN
Parameters need to adjust in barman.conf
Global section of in barman.conf ,Global section name is [barman]
DB- server section from barman.conf
pg-remote is server name i have given .
Parameters need to adjust in postgresql.conf and pg_hba.conf on DB server .
Execute below command
yum install -y centos-release-SCL
yum install -y python27
yum install python-six
yum install python-argparse
yum install python-argcomplete
yum install python-argh
curl "https://bootstrap.pypa.io/get-pip.py" -o
"get-pip.py"
python get-pip.py
https://pypi.python.org/pypi/python-dateutil/2.6.1
tar -xvf python-dateutil-2.6.1.tar.gz
python setup.py build
python setup.py install
pip install -U pip
pip install psycopg2
pip install argh
pip install argcomplete
|
Below are the steps to install BARMAN
https://sourceforge.net/projects/pgbarman/?source=typ_redirect
tar -xvf barman-2.3.tar.gz
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/PostgreSQL9.6S/lib
export PATH=/opt/PostgreSQL9.6S/bin/:$PATH
python setup.py build
python setup.py install
useradd -m -d /home/barman/ barman
chown barman:root /etc/barman
mkdir -p /etc/barman
cp /barman-2.3/doc/barman.conf /etc/barman
|
Parameters need to adjust in barman.conf
Global section of in barman.conf ,Global section name is [barman]
[barman]
barman_home =
/var/lib/barman - Backup and wal path
barman_user = barman
log_file =
/var/log/barman/barman.log - Log file
compression = gzip
minimum_redundancy = 1
immediate_checkpoint = true
|
DB- server section from barman.conf
[pg-remote]
description = "PostgreSQL Server"
ssh_command = ssh
postgres@192.168.213.141
conninfo = host=192.168.213.141
user=postgres port=5411
archiver=on
streaming_archiver = off
reuse_backup = link
|
Parameters need to adjust in postgresql.conf and pg_hba.conf on DB server .
postgresql.conf entries
listen_addresses = *
max_wal_senders = 3
archive_mode = on
wal_level=logical/replica/archive
archive_command = rsync -a %p barman@192.168.213.236:/var/lib/barman/pg-remote/incoming/%f
To get location of wal_dir on barman server ,Execute below command
//barman show-server pg-remote |grep incoming_wals_directory
//incoming_wals_directory: /var/lib/barman/pg-remote/incoming/
pg_hba.conf entries
Allow replication user connection from that server .
host all all 192.168.213.236/32 trust
host replication postgres 192.168.213.236/32 trust
|
Execute below command
/usr/bin/barman archive-wal pg-remote
Where pg-remote is server name .
Below image shows some of the ,Examples .
/usr/bin/barman archive-wal
pg-remote
/usr/bin/barman check pg-remote
/usr/bin/barman list-server
/usr/bin/barman status
pg-remote
/usr/bin/barman show-server
pg-remote
|
Now we will take a backup for one server .
/usr/bin/barman backup
pg-remote
|
List out the backups ,By using below commands .
Now,Lets restore some backup of remote host .
Very Nice ......
ReplyDeletehello, can you help me" goog morning..
ReplyDeleteel sistema de bases de datos fue interrumpido; última vez en funcionamiento en 2018-02-04 01:16:08 CST
2019-03-13 08:23:17 CST [2947-2] LOG: comenzando el proceso de recuperación hasta 2018-02-04 01:00:00-06
cp: no se puede efectuar `stat' sobre «barman_xlog/000000010000030E0000003D»: No existe el archivo o el directorio
2019-03-13 08:23:17 CST [2947-3] LOG: el registro del punto de control no es válido
2019-03-13 08:23:17 CST [2947-4] FATAL: no se pudo localizar el registro del punto de control requerido
2019-03-13 08:23:17 CST [2947-5] HINT: Si no está restaurando un respaldo, intente eliminando «/var/lib/postgresql/idempiere_hmil18/backup_label».
2019-03-13 08:23:17 CST [2946-1] LOG: proceso de inicio (PID 2947) terminó con código de salida 1
2019-03-13 08:23:17 CST [2946-2] LOG: abortando el inicio debido a una falla en el procesamiento de inicio