Data Backup and Recovery
Using barman to achieve data backup and recovery, the AntDB team has made some optimizations to enhance the functionality of barman.
The features that can be implemented include:
• Archive management
• Full backup
• Incremental backups
• Set backup policy
• Local backups
• Remote Backups
• Compressed Backups
• Global Consistent Recovery
• Remote Recovery
When using it, you need to confirm that
• barman host to the host of the node to be backed up is ssh-encrypted
• Host of the node to be backed up to the host of the barman is ssh free
• The archive mode of each node needs to be turned on
• The wal log of each node needs to be archived to the host where barman is located and managed by barman.
The official documentation for barman: http://docs.pgbarman.org/release/2.11/
Create a barrier
In the cluster version, AntDB uses the barrier technology to achieve global consistency in recovery, so you need to create the barrier in the cluster periodically so that you can select the barrier id for recovery when recovering. It is recommended to create a barrier every minute in the cluster by crontab, the operation of creating a barrier will not cause any pressure on the cluster, so don't worry.
Connectcoordinator or gtmcoord to create a barrier:
postgres=# create barrier '20200831';
CLUSTER BARRIER 20200831
Timed script to create a barrier, executed once a minute:
#!/bin/bash
# * * * * * sh create_barrier.sh >> /data/antdb/hostmon/log/create_barrier.log 2>&1
source /home/antdb/.bashrc
barrier_id=`date "+%Y_%m_%d_%H_%M" `
coordhost="10.1.226.201"
coordport="17322"
dbname="postgres"
psqlconn="psql -d $dbname -h $coordhost -p $coordport"
$psqlconn -c "create barrier '$barrier_id';"
if [ `echo $?` -eq 0 ]; then
echo `date "+%Y-%m-%d %H:%M:%S" ` "create barrier $barrier_id succuessed"
else
echo `date "+%Y-%m-%d %H:%M:%S" ` "create barrier $barrier_id failed"
fi
• Download the barman dependencies to a local folder via pip on a host with an external network connection and package them:
pip download -d /tmp/barman barman
pip download -d /tmp/barman argcomplete
tar zcvf barman.tar.gz barman
• Upload the package file of pip, setuptools, and barman to the offline environment, unzip it, and install:
Install pip, setuptools with source code
tar zxvf barman.tar.gz
tar zxvf pip-19.3.1.tar.gz
unzip setuptools-42.0.2.zip
cd pip-19.3.1 && sudo python setup.py install
cd ..
cd setuptools-42.0.2 && sudo python setup.py install
cd ..
• Install the barman dependencies offline via pip.
sudo pip install --no-index --ignore-installed --find-links=barman barman
sudo pip install --no-index --ignore-installed --find-links=barman argcomplete
• --find-linksspecify the path where the barman package file will be extracted.
Alternate address of the file: https://asiainfo.gokuai.com/file/afbxdv51048bhj1837w767zd31cz05s6#! ::barman:
Download adb-barman with source code
Download at: https://asiainfo.gokuai.com/file/afbxdv51048bhj1837w767zd31cz05s6#!::barman:
Install barman to the current user:
unzip adb-barman-master.zip
cd adb-barman-master
./setup.py install --user
...
Installing barman script to /home/antdb/.local/bin
...
Configure environment variables:
Load the $HOME/.local/bininto the environment variables $PATH.
export PATH=$ADBHOME/bin:$HOME/.local/bin$PATH:$HOME/bin:
Check the path to barman:
[antdb@localhost1 ~/barman]$ which barman
~/.local/bin/barman