Jump to content

Postgresql Backup via Barman backup at Muthoot group: Difference between revisions

From TetraWiki
Created page with " == Backup Implemenation at Muthoot Group 's Live PostgreSql Server == ==Environment== 1.Live PG server - 192.168.1.133 2.Backup Server - 192.168.1.132 ==Software Used== B..."
 
No edit summary
Line 14: Line 14:
==Installation process==
==Installation process==


please install barman on backup server i.e 192.168.1.132
Download the Rpm pakages from Sourceforge
Download the Rpm pakages from Sourceforge
  wget http://downloads.sourceforge.net/project/pgbarman/1.1.1/barman-1.1.1-1.rhel6.noarch.rpm
  wget http://downloads.sourceforge.net/project/pgbarman/1.1.1/barman-1.1.1-1.rhel6.noarch.rpm
Line 63: Line 64:
  pg_ctl reload  
  pg_ctl reload  


Make archieve on postgres server  
Make archieve on postgres server (.133) in postgresql.conf


archive_mode = on
archive_command = 'rsync -a %p barman@backup:INCOMING_WALS_DIRECTORY/%f'


Restart the Postgresql Server ( reloading will not help )


Restart the Postgresql Server
Now Check the status on barman server (.132)
barman show-server main


barman show-server main
It should show something like below 
Server main:
Server main:
active: true
active: true
Line 97: Line 102:
ident_file: /var/lib/pgsql/data/pg_ident.conf
ident_file: /var/lib/pgsql/data/pg_ident.conf


-bash-4.1$ barman check main
barman check main
Server main:
Server main:
ssh: OK
ssh: OK

Revision as of 12:24, 10 December 2012

Backup Implemenation at Muthoot Group 's Live PostgreSql Server

Environment

1.Live PG server - 192.168.1.133 2.Backup Server - 192.168.1.132

Software Used

Barman Backup Software for PostgreSql - http://www.pgbarman.org/ Document Refered - http://docs.pgbarman.org/

Installation process

please install barman on backup server i.e 192.168.1.132 Download the Rpm pakages from Sourceforge

wget http://downloads.sourceforge.net/project/pgbarman/1.1.1/barman-1.1.1-1.rhel6.noarch.rpm
wget http://downloads.sourceforge.net/project/pgbarman/rhel6-deps/python-argh-0.15.0-1.rhel6.noarch.rpm

Satisfy it dependecies

yum install python-argh
yum install python-argparse
yum install python-psycopg2

Install the Rpms rpm -Uvh python-argh-0.15.0-1.rhel6.noarch.rpm barman-1.1.1-1.rhel6.noarch.rpm

Build Password less setup

SSH Password less bi-direction setup for postgres ( 192.168.1.133 ) and barman( 192.168.1.132 ) user You should be able to login on ssh from .133 with user postgres to .132 on barman user without password and Visa-Versa

Set the following in /etc/barman.conf

[barman]
; Main directory
barman_home = /var/lib/barman
; System user
barman_user = barman
; Log location
log_file = /var/log/barman/barman.log
; Default compression level: possible values are None (default), bzip2, gzip or custom
compression = gzip
; Pre/post backup hook scripts
;pre_backup_script = env | grep ^BARMAN
;post_backup_script = env | grep ^BARMAN
;; ; 'main' PostgreSQL Server configuration
[main]
;; ; Human readable description
description =  "Main PostgreSQL Database"
;;
;; ; SSH options
ssh_command = ssh postgres@192.168.1.133
;;
;; ; PostgreSQL connection string
conninfo = host=192.168.1.133 user=postgres

Also Ensure that .132 is trusted on main postgresql server .133 by adding the line in pg_hba.conf

host    all             all             192.168.1.132/32          trust

and Reload the config via

pg_ctl reload 

Make archieve on postgres server (.133) in postgresql.conf

archive_mode = on
archive_command = 'rsync -a %p barman@backup:INCOMING_WALS_DIRECTORY/%f'

Restart the Postgresql Server ( reloading will not help )

Now Check the status on barman server (.132)

barman show-server main

It should show something like below Server main: active: true description: Main PostgreSQL Database ssh_command: ssh postgres@192.168.1.133 conninfo: host=192.168.1.133 user=postgres backup_directory: /var/lib/barman/main basebackups_directory: /var/lib/barman/main/base wals_directory: /var/lib/barman/main/wals incoming_wals_directory: /var/lib/barman/main/incoming lock_file: /var/lib/barman/main/main.lock compression: gzip custom_compression_filter: None custom_decompression_filter: None retention_policy: None wal_retention_policy: None pre_backup_script: None post_backup_script: None current_xlog: 00000001000000010000000E last_shipped_wal: None archive_command: rsync -a %p barman@192.168.1.132:/var/lib/barman/main/incoming/%f server_txt_version: 8.4.13 data_directory: /var/lib/pgsql/data archive_mode: on config_file: /var/lib/pgsql/data/postgresql.conf hba_file: /var/lib/pgsql/data/pg_hba.conf ident_file: /var/lib/pgsql/data/pg_ident.conf

barman check main

Server main: ssh: OK PostgreSQL: OK archive_mode: OK archive_command: OK directories: OK compression settings: OK


ln -s /home/postreg_barman_backup/main /var/lib/barman/


barman backup main

Crontab entry

Restoration