Barman需要用到psql客户端,所以需要在Barman服务器安装psql数据库 1 linux操作系统环境准备: python版本:2.6或2.7 yum -y install epel-release.noarch yum -y install python-argcomplete.noarch yum -y install python-argh.noarch yum -y install python-psycopg2.x86_64 python-psycopg2-doc.x86_64 yum -y install python-dateutil.noarch python-dateutil15.noarch yum -y install rsync.x86_64 2 创建barman系统用户 groupadd barman useradd -g barman barman passwd barman 3 安装Barman # tar -zxvf barman-1.4.0.tar.gz # chown -R barman:barman barman-1.4.0 [barman@localhost barman-1.4.0]$ ./setup.py build [root@localhost barman-1.4.0]# ./setup.py install [root@localhost barman-1.4.0]# su - barman [barman@localhost ~]$ cd /software/barman-1.4.0 [barman@localhost barman-1.4.0]$ ./setup.py install --user 将Barman配置文件Barman.conf拷贝到~/.barman.conf [barman@localhost ~]$ cp /software/barman-1.4.0/doc/barman.conf ~/.barman.conf [barman@localhost ~]$ ls -al -rw-r--r-- 1 barman barman 2863 Feb 12 15:57 .barman.conf 4 配置.barman.conf文件: [main-test] description = "test" ssh_command = ssh barman@barmanIP conninfo = host=IP user=postgres incoming_wals_directory: /barman_backup/main-test/incoming minimum_redundancy = 1 retention_policy = REDUNDANCY 2 5 Barman服务器与数据库服务器之间做互信 [barman@localhost ~]$ ssh-keygen -t rsa [barman@localhost ~]$ ssh-copy-id -i .ssh/id_rsa.pub barman@IP [barman@localhost ~]$ ssh barman@IP [barman@erp ~]$ ssh-keygen -t rsa [barman@erp ~]$ ssh-copy-id -i .ssh/id_rsa.pub barman@barmanIP [barman@erp ~]$ ssh barman@barmanIP 6 基于时间点的恢复: --基于时间的恢复将数据库恢复到read only状态 [barman@slony ~]$ barman recover --target-time "2015-02-27 15:25:00" --remote-ssh-command "ssh postgres@IP" main-test 20150227T141803 /home/postgres/pgdata ********************************************************************************** Barman备份standby数据库: 在standby库操作: 安装pgespresso-master.zip --https://github.com/2ndquadrant-it/pgespresso [postgres@segdb1 pgespresso-master]$ make [postgres@segdb1 pgespresso-master]$make install [postgres@segdb1 ~]$ psql postgres=# CREATE EXTENSION pgespresso; 在Barman服务器: vi .barman.conf 添加 backup_options = concurrent_backup 注: 必须将主服务器的归档日志归档到:/home/barman/barman/main-test-standby/incoming目录下 archive_command = 'rsync -a %p barman@barmanIP:/barman_backup/main-test/incoming/%f'