>>pgespresso <<
pgespresso extension (https://github.com/2ndquadrant-it/pgespresso) is used for enabling stop and start backup mode with pgespresso_start_backup and pgespresso_stop_backup on Slave server.This is extra module or extension which has to be create on master and slave.
pgespresso_start_backup (label, fast)
pgespresso_start_backup is used to start taking a concurrent backup. It returns a backup label file that the user is responsible for placing in the $PGDATA of the backup AFTER the backup has been taken. The label file must not be written to the data directory of the server from which the backup is taken because this type of backup presumes and allows that more than one backup may be in progress at any one time. The label file contains the user-supplied label string (typically this would be used to tell where the backup dump will be stored) and the starting time and starting WAL location for the dump.
pgespresso_stop_backup (label_content)
pgespresso_stop_backup is used to stop a concurrent backup. It returns the XLOG filename containing end of backup location, combining both the TLI and the end location.
pgespresso_abort_backup ()
pgespresso_abort_backup aborts a running concurrent backup.
Step1:Install and configure Postgresql9.5 and pgespresso
PostgreSQL 9.4 link : https://ftp.postgresql.org/pub/source/v9.4.0/postgresql-9.4.0.tar.bz2
pgespresso link : https://github.com/2ndquadrant-it/pgespresso
Export pg env variables and the start the Setup of pgespresso.
[root@localhost tmp]# unzip master
[root@localhost tmp]# cd pgespresso-master/
[root@localhost pgespresso-master]# make
make: Nothing to be done for `all'.
[root@localhost pgespresso-master]# make install
/bin/mkdir -p '/opt/Postgres94/share/postgresql/extension'
/bin/mkdir -p '/opt/Postgres94/share/postgresql/extension'
/bin/mkdir -p '/opt/Postgres94/lib/postgresql'
/usr/bin/install -c -m 644 pgespresso.control '/opt/Postgres94/share/postgresql/extension/'
/usr/bin/install -c -m 644 pgespresso--1.0.sql '/opt/Postgres94/share/postgresql/extension/'
/usr/bin/install -c -m 755 pgespresso.so '/opt/Postgres94/lib/postgresql/'
Step2:Install prerequisite before installing pgbarman below are necessary prerequisite.
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
then configure and install pgbarman
pgbarman link : https://sourceforge.net/projects/pgbarman/files/1.5.1/barman-1.5.1.tar.gz/download
Step3: Set the parameters in barman.conf and provide conninfo of slave server (In example slave is running on 5433 port) as shown below
[barman]
barman_home = /home/barman
barman_user = barman
log_file = /home/barman/barman.log
compression = gzip
reuse_backup = link
retention_policy = REDUNDANCY 4
bandwidth_limit = 4000
network_compression = true
backup_options = concurrent_backup
last_backup_maximum_age = 1 DAY
[main]
description = "PostgreSQL Database Hot Standby"
ssh_command = ssh postgres@127.0.0.1
conninfo = host=127.0.0.1 user=postgres port=5433 --Slave details
minimum_redundancy = 1
Step4:Make passwordless authentication between master,slave,barman servers.
Step5:Set the parametes in postgresql.conf on master as given below
archive_mode = on
wal_level = hot_standby
archive_command = 'rsync -a %p barman@127.0.0.1:/home/barman/main/incoming/%f'
then restart the master , setup streaming replication(slave is on port 5433) and created extension pgespresso on master.
Step6: Now Check wether barman can connect to postgres or not .
[barman@localhost ~]$ barman check main
Server main:
PostgreSQL: OK
wal_level: OK
directories: OK
retention policy settings: OK
backup maximum age: OK (no last_backup_maximum_age provided)
compression settings: OK
failed backups: OK (there are 0 failed backups)
minimum redundancy requirements: FAILED (have 0 backups, expected at least 1)
ssh: OK (PostgreSQL server)
pgespresso extension: OK
archive_mode: OK
archive_command: OK
continuous archiving: OK
archiver errors: OK
Note : here 'main' is name for slave "postgres instance" which is declared in barman.conf.
Step7 : Below command gives the information of the postgres server
[barman@localhost ~]$ barman show-server main
Server main:
active: True
archive_command: rsync -a %p barman@127.0.0.1:/home/barman/main/incoming/%f
archive_mode: on
archived_count: 0
archiver: True
backup_directory: /home/barman/main
backup_method: rsync
backup_options: BackupOptions(['concurrent_backup'])
bandwidth_limit: 4000
basebackup_retry_sleep: 30
basebackup_retry_times: 1
basebackups_directory: /home/barman/main/base
compression: gzip
config_file: /home/postgres/data2/postgresql.conf
conninfo: host=127.0.0.1 user=postgres dbname=postgres port=5433
current_archived_wals_per_second: 0.0
current_size: 828503628
current_xlog: None
custom_compression_filter: None
custom_decompression_filter: None
data_directory: /home/postgres/data2
description: Main PostgreSQL Database
disabled: False
errors_directory: /home/barman/main/errors
Step8 : Take first full backup of main using barman
[barman@localhost ~]$ barman backup main
Starting backup for server main in /home/barman/main/base/20160227T171537
Backup start at xlog location: 0/8F0000C8 (00000001000000000000008F, 000000C8)
This is the first backup for server main
Copying files.
Copy done.
Asking PostgreSQL server to finalize the backup.
Backup size: 790.2 MiB. Actual size on disk: 790.2 MiB (-0.00% deduplication ratio).
Backup end at xlog location: 0/90000000 (00000001000000000000008F, 00000000)
Backup completed
Processing xlog segments from file archival for main
00000001000000000000008E
Step9: Create database and use pgbench to load data then take incremental backup of main using barman.
Adding data to postgres :
postgres=# create database test;
CREATE DATABASE
postgres=# \q
[postgres@localhost ~]$ pgbench -i -d test
NOTICE: table "pgbench_history" does not exist, skipping
NOTICE: table "pgbench_tellers" does not exist, skipping
NOTICE: table "pgbench_accounts" does not exist, skipping
NOTICE: table "pgbench_branches" does not exist, skipping
creating tables...
100000 of 100000 tuples (100%) done (elapsed 0.24 s, remaining 0.00 s).
vacuum...
set primary keys...
done.
[postgres@localhost ~]$ psql -d test
psql (9.4.6)
Type "help" for help.
test=# \dt
List of relations
Schema | Name | Type | Owner
--------+------------------+-------+----------
public | pgbench_accounts | table | postgres
public | pgbench_branches | table | postgres
public | pgbench_history | table | postgres
public | pgbench_tellers | table | postgres
(4 rows)
test=#
Now take incremental backup using barman :
[barman@localhost ~]$ barman backup --reuse=link main
Starting backup for server main in /home/barman/main/base/20160227T172458
Backup start at xlog location: 0/8F012DE8 (00000001000000000000008F, 00012DE8)
Copying files.
Copy done.
Asking PostgreSQL server to finalize the backup.
Backup size: 42.4 MiB. Actual size on disk: 1.3 MiB (-96.94% deduplication ratio).
Backup end at xlog location: 0/90000000 (00000001000000000000008F, 00000000)
Backup completed
Note : --reuse= link is used to link the main full backup . This will backup only modified or changed files from main(postgres) .
Step10: To list out the backus follow below command
[barman@localhost ~]$ barman list-backup main
main 20160227T172458 - Sat Feb 27 17:25:02 2016 - Size: 42.4 MiB - WAL Size: 0 B
main 20160227T171537 - Sat Feb 27 17:19:04 2016 - Size: 790.2 MiB - WAL Size: 0 B
There are 2 backups listed .
Step11: Now lets recover from backup
[barman@localhost ~]$ barman recover main 20160227T172458 /tmp/recover
Processing xlog segments from file archival for main
000000010000000000000093
000000010000000000000094
000000010000000000000095
000000010000000000000096
000000010000000000000097
000000010000000000000098
000000010000000000000099
Starting local restore for server main using backup 20160227T172458
Destination directory: /tmp/recover
Copying the base backup.
Copying required WAL segments.
Generating archive status files
Identify dangerous settings in destination directory.
IMPORTANT
These settings have been modified to prevent data losses
postgresql.conf line 207: archive_command = false
Your PostgreSQL server has been successfully prepared for recovery!
Backup is restored at location /tmp/recover and while recovering user have to give latest backup ID
"barman recover main latest_Backup_ID /tmp/recover"
Step12: Change owner of recover instance from barman to postgres.
[root@localhost ~]# chown -R postgres:postgres /tmp/recover
[root@localhost ~]# ll /tmp/recover/
total 152
-rw-rw-r--. 1 postgres postgres 218 Feb 27 17:25 backup_label
-rw-------. 1 postgres postgres 206 Feb 27 14:06 backup_label.old
drwx------. 6 postgres postgres 4096 Feb 27 16:21 base
drwx------. 2 postgres postgres 4096 Feb 27 17:24 global
drwx------. 2 postgres postgres 4096 Feb 27 14:06 pg_clog
drwx------. 2 postgres postgres 4096 Feb 27 14:06 pg_dynshmem
-rw-------. 1 postgres postgres 4465 Feb 27 14:06 pg_hba.conf
-rw-------. 1 postgres postgres 1636 Feb 27 14:06 pg_ident.conf
drwx------. 2 postgres postgres 4096 Feb 27 17:11 pg_log
drwx------. 4 postgres postgres 4096 Feb 27 14:06 pg_logical
drwx------. 4 postgres postgres 4096 Feb 27 14:06 pg_multixact
drwx------. 2 postgres postgres 4096 Feb 27 17:11 pg_notify
drwx------. 2 postgres postgres 4096 Feb 27 14:06 pg_replslot
drwx------. 2 postgres postgres 4096 Feb 27 14:06 pg_serial
drwx------. 2 postgres postgres 4096 Feb 27 14:06 pg_snapshots
drwx------. 2 postgres postgres 4096 Feb 27 17:11 pg_stat
drwx------. 2 postgres postgres 4096 Feb 27 17:24 pg_stat_tmp
drwx------. 2 postgres postgres 4096 Feb 27 14:06 pg_subtrans
drwx------. 2 postgres postgres 4096 Feb 27 14:06 pg_tblspc
drwx------. 2 postgres postgres 4096 Feb 27 14:06 pg_twophase
-rw-------. 1 postgres postgres 4 Feb 27 14:06 PG_VERSION
drwx------. 3 postgres postgres 4096 Feb 27 17:27 pg_xlog
-rw-------. 1 postgres postgres 88 Feb 27 17:27 postgresql.auto.conf
-rw-------. 1 postgres postgres 88 Feb 27 14:06 postgresql.auto.conf.origin
-rw-------. 1 postgres postgres 21384 Feb 27 17:27 postgresql.conf
-rw-------. 1 postgres postgres 21351 Feb 27 17:10 postgresql.conf.origin
-rw-------. 1 postgres postgres 35 Feb 27 17:11 postmaster.opts
Step13: start recovered cluster using pg_ctl
[postgres@localhost ~]$ psql -p 5434
psql (9.4.6)
Type "help" for help.
postgres=# show data_directory ;
data_directory
----------------
/tmp/recover
(1 row)
postgres=# \c test
You are now connected to database "test" as user "postgres".
test=# \dt
List of relations
Schema | Name | Type | Owner
--------+------------------+-------+----------
public | pgbench_accounts | table | postgres
public | pgbench_branches | table | postgres
public | pgbench_history | table | postgres
public | pgbench_tellers | table | postgres
(4 rows)
test=#
*************************************
Observed activity on slave and found that barman was taking backup from slave below is evidence :
postgres=# show port;
port
------
5433
(1 row)
postgres=# select pg_is_in_recovery();
pg_is_in_recovery
-------------------
t
(1 row)
postgres=# select * from pg_stat_activity ;
datid | datname | pid | usesysid | usename | application_name | client_addr | client_hostname | client_port | backend_start | xact_start
| query_start | state_change | waiting | state | backend_xid | backend_xmin | query
-------+----------+-------+----------+----------+------------------+-------------+-----------------+-------------+----------------------------------+------------------------------
----+----------------------------------+----------------------------------+---------+--------+-------------+--------------+--------------------------------------------------------
---------------------------
13003 | postgres | 97373 | 10 | postgres | | 127.0.0.1 | | 41877 | 2016-02-27 16:32:41.54456+05:30 | 2016-02-27 16:32:42.064071+05
:30 | 2016-02-27 16:32:42.064123+05:30 | 2016-02-27 16:32:42.064124+05:30 | f | active | | 1919 | SELECT pgespresso_start_backup('Barman backup main 2016
0227T163242',false), now()
13003 | postgres | 95772 | 10 | postgres | psql | | | -1 | 2016-02-27 16:28:57.001512+05:30 | 2016-02-27 16:32:47.167849+05
:30 | 2016-02-27 16:32:47.167849+05:30 | 2016-02-27 16:32:47.167853+05:30 | f | active | | 1919 | select * from pg_stat_activity ;
(2 rows)
postgres=# select * from pg_stat_activity ;
datid | datname | pid | usesysid | usename | application_name | client_addr | client_hostname | client_port | backend_start | xact_start
| query_start | state_change | waiting | state | backend_xid | backend_xmin | query
-------+----------+-------+----------+----------+------------------+-------------+-----------------+-------------+----------------------------------+------------------------------
----+----------------------------------+----------------------------------+---------+--------+-------------+--------------+--------------------------------------------------------
---------------------------
13003 | postgres | 97373 | 10 | postgres | | 127.0.0.1 | | 41877 | 2016-02-27 16:32:41.54456+05:30 | 2016-02-27 16:32:42.064071+05
:30 | 2016-02-27 16:32:42.064123+05:30 | 2016-02-27 16:32:42.064124+05:30 | f | active | | 1919 | SELECT pgespresso_start_backup('Barman backup main 2016
0227T163242',false), now()
13003 | postgres | 95772 | 10 | postgres | psql | | | -1 | 2016-02-27 16:28:57.001512+05:30 | 2016-02-27 16:32:49.423868+05
:30 | 2016-02-27 16:32:49.423868+05:30 | 2016-02-27 16:32:49.423872+05:30 | f | active | | 1919 | select * from pg_stat_activity ;
(2 rows)
pgespresso extension (https://github.com/2ndquadrant-it/pgespresso) is used for enabling stop and start backup mode with pgespresso_start_backup and pgespresso_stop_backup on Slave server.This is extra module or extension which has to be create on master and slave.
pgespresso_start_backup (label, fast)
pgespresso_start_backup is used to start taking a concurrent backup. It returns a backup label file that the user is responsible for placing in the $PGDATA of the backup AFTER the backup has been taken. The label file must not be written to the data directory of the server from which the backup is taken because this type of backup presumes and allows that more than one backup may be in progress at any one time. The label file contains the user-supplied label string (typically this would be used to tell where the backup dump will be stored) and the starting time and starting WAL location for the dump.
pgespresso_stop_backup (label_content)
pgespresso_stop_backup is used to stop a concurrent backup. It returns the XLOG filename containing end of backup location, combining both the TLI and the end location.
pgespresso_abort_backup ()
pgespresso_abort_backup aborts a running concurrent backup.
Step1:Install and configure Postgresql9.5 and pgespresso
PostgreSQL 9.4 link : https://ftp.postgresql.org/pub/source/v9.4.0/postgresql-9.4.0.tar.bz2
pgespresso link : https://github.com/2ndquadrant-it/pgespresso
Export pg env variables and the start the Setup of pgespresso.
[root@localhost tmp]# unzip master
[root@localhost tmp]# cd pgespresso-master/
[root@localhost pgespresso-master]# make
make: Nothing to be done for `all'.
[root@localhost pgespresso-master]# make install
/bin/mkdir -p '/opt/Postgres94/share/postgresql/extension'
/bin/mkdir -p '/opt/Postgres94/share/postgresql/extension'
/bin/mkdir -p '/opt/Postgres94/lib/postgresql'
/usr/bin/install -c -m 644 pgespresso.control '/opt/Postgres94/share/postgresql/extension/'
/usr/bin/install -c -m 644 pgespresso--1.0.sql '/opt/Postgres94/share/postgresql/extension/'
/usr/bin/install -c -m 755 pgespresso.so '/opt/Postgres94/lib/postgresql/'
Step2:Install prerequisite before installing pgbarman below are necessary prerequisite.
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
then configure and install pgbarman
pgbarman link : https://sourceforge.net/projects/pgbarman/files/1.5.1/barman-1.5.1.tar.gz/download
Step3: Set the parameters in barman.conf and provide conninfo of slave server (In example slave is running on 5433 port) as shown below
[barman]
barman_home = /home/barman
barman_user = barman
log_file = /home/barman/barman.log
compression = gzip
reuse_backup = link
retention_policy = REDUNDANCY 4
bandwidth_limit = 4000
network_compression = true
backup_options = concurrent_backup
last_backup_maximum_age = 1 DAY
[main]
description = "PostgreSQL Database Hot Standby"
ssh_command = ssh postgres@127.0.0.1
conninfo = host=127.0.0.1 user=postgres port=5433 --Slave details
minimum_redundancy = 1
Step4:Make passwordless authentication between master,slave,barman servers.
Step5:Set the parametes in postgresql.conf on master as given below
archive_mode = on
wal_level = hot_standby
archive_command = 'rsync -a %p barman@127.0.0.1:/home/barman/main/incoming/%f'
then restart the master , setup streaming replication(slave is on port 5433) and created extension pgespresso on master.
Step6: Now Check wether barman can connect to postgres or not .
[barman@localhost ~]$ barman check main
Server main:
PostgreSQL: OK
wal_level: OK
directories: OK
retention policy settings: OK
backup maximum age: OK (no last_backup_maximum_age provided)
compression settings: OK
failed backups: OK (there are 0 failed backups)
minimum redundancy requirements: FAILED (have 0 backups, expected at least 1)
ssh: OK (PostgreSQL server)
pgespresso extension: OK
archive_mode: OK
archive_command: OK
continuous archiving: OK
archiver errors: OK
Note : here 'main' is name for slave "postgres instance" which is declared in barman.conf.
Step7 : Below command gives the information of the postgres server
[barman@localhost ~]$ barman show-server main
Server main:
active: True
archive_command: rsync -a %p barman@127.0.0.1:/home/barman/main/incoming/%f
archive_mode: on
archived_count: 0
archiver: True
backup_directory: /home/barman/main
backup_method: rsync
backup_options: BackupOptions(['concurrent_backup'])
bandwidth_limit: 4000
basebackup_retry_sleep: 30
basebackup_retry_times: 1
basebackups_directory: /home/barman/main/base
compression: gzip
config_file: /home/postgres/data2/postgresql.conf
conninfo: host=127.0.0.1 user=postgres dbname=postgres port=5433
current_archived_wals_per_second: 0.0
current_size: 828503628
current_xlog: None
custom_compression_filter: None
custom_decompression_filter: None
data_directory: /home/postgres/data2
description: Main PostgreSQL Database
disabled: False
errors_directory: /home/barman/main/errors
Step8 : Take first full backup of main using barman
[barman@localhost ~]$ barman backup main
Starting backup for server main in /home/barman/main/base/20160227T171537
Backup start at xlog location: 0/8F0000C8 (00000001000000000000008F, 000000C8)
This is the first backup for server main
Copying files.
Copy done.
Asking PostgreSQL server to finalize the backup.
Backup size: 790.2 MiB. Actual size on disk: 790.2 MiB (-0.00% deduplication ratio).
Backup end at xlog location: 0/90000000 (00000001000000000000008F, 00000000)
Backup completed
Processing xlog segments from file archival for main
00000001000000000000008E
Step9: Create database and use pgbench to load data then take incremental backup of main using barman.
Adding data to postgres :
postgres=# create database test;
CREATE DATABASE
postgres=# \q
[postgres@localhost ~]$ pgbench -i -d test
NOTICE: table "pgbench_history" does not exist, skipping
NOTICE: table "pgbench_tellers" does not exist, skipping
NOTICE: table "pgbench_accounts" does not exist, skipping
NOTICE: table "pgbench_branches" does not exist, skipping
creating tables...
100000 of 100000 tuples (100%) done (elapsed 0.24 s, remaining 0.00 s).
vacuum...
set primary keys...
done.
[postgres@localhost ~]$ psql -d test
psql (9.4.6)
Type "help" for help.
test=# \dt
List of relations
Schema | Name | Type | Owner
--------+------------------+-------+----------
public | pgbench_accounts | table | postgres
public | pgbench_branches | table | postgres
public | pgbench_history | table | postgres
public | pgbench_tellers | table | postgres
(4 rows)
test=#
Now take incremental backup using barman :
[barman@localhost ~]$ barman backup --reuse=link main
Starting backup for server main in /home/barman/main/base/20160227T172458
Backup start at xlog location: 0/8F012DE8 (00000001000000000000008F, 00012DE8)
Copying files.
Copy done.
Asking PostgreSQL server to finalize the backup.
Backup size: 42.4 MiB. Actual size on disk: 1.3 MiB (-96.94% deduplication ratio).
Backup end at xlog location: 0/90000000 (00000001000000000000008F, 00000000)
Backup completed
Note : --reuse= link is used to link the main full backup . This will backup only modified or changed files from main(postgres) .
Step10: To list out the backus follow below command
[barman@localhost ~]$ barman list-backup main
main 20160227T172458 - Sat Feb 27 17:25:02 2016 - Size: 42.4 MiB - WAL Size: 0 B
main 20160227T171537 - Sat Feb 27 17:19:04 2016 - Size: 790.2 MiB - WAL Size: 0 B
There are 2 backups listed .
Step11: Now lets recover from backup
[barman@localhost ~]$ barman recover main 20160227T172458 /tmp/recover
Processing xlog segments from file archival for main
000000010000000000000093
000000010000000000000094
000000010000000000000095
000000010000000000000096
000000010000000000000097
000000010000000000000098
000000010000000000000099
Starting local restore for server main using backup 20160227T172458
Destination directory: /tmp/recover
Copying the base backup.
Copying required WAL segments.
Generating archive status files
Identify dangerous settings in destination directory.
IMPORTANT
These settings have been modified to prevent data losses
postgresql.conf line 207: archive_command = false
Your PostgreSQL server has been successfully prepared for recovery!
Backup is restored at location /tmp/recover and while recovering user have to give latest backup ID
"barman recover main latest_Backup_ID /tmp/recover"
Step12: Change owner of recover instance from barman to postgres.
[root@localhost ~]# chown -R postgres:postgres /tmp/recover
[root@localhost ~]# ll /tmp/recover/
total 152
-rw-rw-r--. 1 postgres postgres 218 Feb 27 17:25 backup_label
-rw-------. 1 postgres postgres 206 Feb 27 14:06 backup_label.old
drwx------. 6 postgres postgres 4096 Feb 27 16:21 base
drwx------. 2 postgres postgres 4096 Feb 27 17:24 global
drwx------. 2 postgres postgres 4096 Feb 27 14:06 pg_clog
drwx------. 2 postgres postgres 4096 Feb 27 14:06 pg_dynshmem
-rw-------. 1 postgres postgres 4465 Feb 27 14:06 pg_hba.conf
-rw-------. 1 postgres postgres 1636 Feb 27 14:06 pg_ident.conf
drwx------. 2 postgres postgres 4096 Feb 27 17:11 pg_log
drwx------. 4 postgres postgres 4096 Feb 27 14:06 pg_logical
drwx------. 4 postgres postgres 4096 Feb 27 14:06 pg_multixact
drwx------. 2 postgres postgres 4096 Feb 27 17:11 pg_notify
drwx------. 2 postgres postgres 4096 Feb 27 14:06 pg_replslot
drwx------. 2 postgres postgres 4096 Feb 27 14:06 pg_serial
drwx------. 2 postgres postgres 4096 Feb 27 14:06 pg_snapshots
drwx------. 2 postgres postgres 4096 Feb 27 17:11 pg_stat
drwx------. 2 postgres postgres 4096 Feb 27 17:24 pg_stat_tmp
drwx------. 2 postgres postgres 4096 Feb 27 14:06 pg_subtrans
drwx------. 2 postgres postgres 4096 Feb 27 14:06 pg_tblspc
drwx------. 2 postgres postgres 4096 Feb 27 14:06 pg_twophase
-rw-------. 1 postgres postgres 4 Feb 27 14:06 PG_VERSION
drwx------. 3 postgres postgres 4096 Feb 27 17:27 pg_xlog
-rw-------. 1 postgres postgres 88 Feb 27 17:27 postgresql.auto.conf
-rw-------. 1 postgres postgres 88 Feb 27 14:06 postgresql.auto.conf.origin
-rw-------. 1 postgres postgres 21384 Feb 27 17:27 postgresql.conf
-rw-------. 1 postgres postgres 21351 Feb 27 17:10 postgresql.conf.origin
-rw-------. 1 postgres postgres 35 Feb 27 17:11 postmaster.opts
Step13: start recovered cluster using pg_ctl
[postgres@localhost ~]$ psql -p 5434
psql (9.4.6)
Type "help" for help.
postgres=# show data_directory ;
data_directory
----------------
/tmp/recover
(1 row)
postgres=# \c test
You are now connected to database "test" as user "postgres".
test=# \dt
List of relations
Schema | Name | Type | Owner
--------+------------------+-------+----------
public | pgbench_accounts | table | postgres
public | pgbench_branches | table | postgres
public | pgbench_history | table | postgres
public | pgbench_tellers | table | postgres
(4 rows)
test=#
*************************************
Observed activity on slave and found that barman was taking backup from slave below is evidence :
postgres=# show port;
port
------
5433
(1 row)
postgres=# select pg_is_in_recovery();
pg_is_in_recovery
-------------------
t
(1 row)
postgres=# select * from pg_stat_activity ;
datid | datname | pid | usesysid | usename | application_name | client_addr | client_hostname | client_port | backend_start | xact_start
| query_start | state_change | waiting | state | backend_xid | backend_xmin | query
-------+----------+-------+----------+----------+------------------+-------------+-----------------+-------------+----------------------------------+------------------------------
----+----------------------------------+----------------------------------+---------+--------+-------------+--------------+--------------------------------------------------------
---------------------------
13003 | postgres | 97373 | 10 | postgres | | 127.0.0.1 | | 41877 | 2016-02-27 16:32:41.54456+05:30 | 2016-02-27 16:32:42.064071+05
:30 | 2016-02-27 16:32:42.064123+05:30 | 2016-02-27 16:32:42.064124+05:30 | f | active | | 1919 | SELECT pgespresso_start_backup('Barman backup main 2016
0227T163242',false), now()
13003 | postgres | 95772 | 10 | postgres | psql | | | -1 | 2016-02-27 16:28:57.001512+05:30 | 2016-02-27 16:32:47.167849+05
:30 | 2016-02-27 16:32:47.167849+05:30 | 2016-02-27 16:32:47.167853+05:30 | f | active | | 1919 | select * from pg_stat_activity ;
(2 rows)
postgres=# select * from pg_stat_activity ;
datid | datname | pid | usesysid | usename | application_name | client_addr | client_hostname | client_port | backend_start | xact_start
| query_start | state_change | waiting | state | backend_xid | backend_xmin | query
-------+----------+-------+----------+----------+------------------+-------------+-----------------+-------------+----------------------------------+------------------------------
----+----------------------------------+----------------------------------+---------+--------+-------------+--------------+--------------------------------------------------------
---------------------------
13003 | postgres | 97373 | 10 | postgres | | 127.0.0.1 | | 41877 | 2016-02-27 16:32:41.54456+05:30 | 2016-02-27 16:32:42.064071+05
:30 | 2016-02-27 16:32:42.064123+05:30 | 2016-02-27 16:32:42.064124+05:30 | f | active | | 1919 | SELECT pgespresso_start_backup('Barman backup main 2016
0227T163242',false), now()
13003 | postgres | 95772 | 10 | postgres | psql | | | -1 | 2016-02-27 16:28:57.001512+05:30 | 2016-02-27 16:32:49.423868+05
:30 | 2016-02-27 16:32:49.423868+05:30 | 2016-02-27 16:32:49.423872+05:30 | f | active | | 1919 | select * from pg_stat_activity ;
(2 rows)
****************************