How to set up Barman (Backup and Recovery Manager for PostgreSQL) under construction - mchau138/jubilant-guacamole GitHub Wiki
Reference : http://docs.pgbarman.org/release/1.5.0/
- System Requirements on barman server hereby called backup server:
Linux/Unix
Python 2.6 or 2.7
Python modules:
argcomplete
argh >= 0.21.2
psycopg2
python-dateutil < 2.0 (since version 2.0 requires python3)
distribute (optional)
PostgreSQL >= 8.3
rsync >= 3.0.4
-
Install barman on backup server: sudo apt-get install barman // This will create the barman user
-
Establish bidirectional SSH connection without password between barman server (backup server) and postgres server (hereby called pg server):
a) On backup server: sudo su - barman barman@backup: ssh-keygen -t rsa // Create the public and private keys without any paraphase cd .ssh copy the content of id_rsa.pub to the authorized_keys file under /var/lib/postgres/.ssh directory on the pg server // Note that authorized_keys file needs to be at 0600 permission
b) Vice versa, on pg server: sudo su - postgres postgres@pg: ssh-keygen -t rsa // Create the public and private keys without any paraphase cd .ssh copy the content of id_rsa.pub to the authorized_keys file under /var/lib/barman/.ssh directory on the backup server // Note that authorized_keys file needs to be at 0600 permission
c) Edit the /etc/hosts file on both servers and add the internal ip of both servers: // can be found on EC2 AWS i.e: xx.xxx.xx.xxx backup xx.xxx.xxx.xxx pg
d) Add the internal ip of backup to the AWS security groups of pg and vice-versa the internal ip of pg to the AWS security groups of backup for SSH 22 protocol.
e) On backup, ssh postgres@pg // as barman user
f) psql -c 'SELECT version()' -h pg -p 5432 -U (db-user) -d (db-name) // Need to add entry in security group for port 5432
g) On pg, ssh barman@backup // as postgres user
-
Edit /etc/barman.conf on backup server: