sudo wget -q -O - \
https://github.com/pgbackrest/pgbackrest/archive/release/2.04.tar.gz | \
sudo tar zx -C /rootsudo apt-get install build-essential libssl-dev libperl-dev
perl -V | grep USE_64_BIT_INT
USE_64_BIT_ALL USE_64_BIT_INT USE_ITHREADS
sudo make -C /root/pgbackrest-release-2.04/src
sudo echo 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main 11' | \
sudo tee -a /etc/apt/sources.list.d/pgdg.listsudo wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
sudo apt-key add -sudo apt-get update
sudo apt-get install postgresql-common
sudo sed -i 's/^\#create\_main\_cluster.*$/create\_main\_cluster \= false/' \
/etc/postgresql-common/createcluster.confsudo apt-get install postgresql-9.4
sudo scp build:/root/pgbackrest-release-2.04/src/pgbackrest /usr/bin
sudo chmod 755 /usr/bin/pgbackrest
sudo apt-get install libdbd-pg-perl libio-socket-ssl-perl libxml-libxml-perl
sudo mkdir -p -m 770 /var/log/pgbackrest
sudo chown postgres:postgres /var/log/pgbackrest
sudo mkdir -p /etc/pgbackrest
sudo mkdir -p /etc/pgbackrest/conf.d
sudo touch /etc/pgbackrest/pgbackrest.conf
sudo chmod 640 /etc/pgbackrest/pgbackrest.conf
sudo chown postgres:postgres /etc/pgbackrest/pgbackrest.conf
sudo -u postgres pgbackrest
pgBackRest 2.04 - General help
Usage:
pgbackrest [options] [command]
Commands:
archive-get Get a WAL segment from the archive.
archive-push Push a WAL segment to the archive.
backup Backup a database cluster.
check Check the configuration.
expire Expire backups that exceed retention.
help Get help.
info Retrieve information about backups.
restore Restore a database cluster.
stanza-create Create the required stanza data.
stanza-delete Delete a stanza.
stanza-upgrade Upgrade a stanza.
start Allow pgBackRest processes to run.
stop Stop pgBackRest processes from running.
version Get version.
Use 'pgbackrest help [command]' for more information.sudo -u postgres /usr/lib/postgresql/9.4/bin/initdb \
-D /var/lib/postgresql/9.4/demo -k -A peersudo pg_createcluster 9.4 demo
Configuring already existing cluster (configuration: /etc/postgresql/9.4/demo, data: /var/lib/postgresql/9.4/demo, owner: 106:110) Ver Cluster Port Status Owner Data directory Log file 9.4 demo 5432 down postgres /var/lib/postgresql/9.4/demo /var/log/postgresql/postgresql-9.4-demo.log
sudo mkdir -p /var/lib/pgbackrest
sudo chmod 750 /var/lib/pgbackrest
sudo chown postgres:postgres /var/lib/pgbackrest
sudo pg_ctlcluster 9.4 demo restart
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stanza-create
P00 INFO: stanza-create command begin 2.04: --log-level-console=info --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/9.4/demo --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --stanza=demo
P00 INFO: stanza-create command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info check
P00 INFO: check command begin 2.04: --log-level-console=info --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/9.4/demo --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --stanza=demo
P00 INFO: WAL segment 000000010000000000000001 successfully stored in the archive at '/var/lib/pgbackrest/archive/demo/9.4-1/0000000100000000/000000010000000000000001-cba88b5d44e9e5215ab6b7c29f37c4814a507ac4.gz'
P00 INFO: check command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo \
--log-level-console=info backupP00 INFO: backup command begin 2.04: --log-level-console=info --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/9.4/demo --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-full=2 --stanza=demo
P00 WARN: no prior backup exists, incr backup has been changed to full
P00 INFO: execute exclusive pg_start_backup() with label "pgBackRest backup started at 2018-07-05 22:51:53": backup begins after the next regular checkpoint completes
P00 INFO: backup start archive = 000000010000000000000002, lsn = 0/2000028
[filtered 754 lines of output]
P01 INFO: backup file /var/lib/postgresql/9.4/demo/base/1/11895 (0B, 100%)
P01 INFO: backup file /var/lib/postgresql/9.4/demo/base/1/11885 (0B, 100%)P00 INFO: full backup size = 19.2MB
P00 INFO: execute exclusive pg_stop_backup() and wait for all WAL segments to archive
P00 INFO: backup stop archive = 000000010000000000000002, lsn = 0/2000128
[filtered 4 lines of output]sudo -u postgres pgbackrest --stanza=demo --type=diff \
--log-level-console=info backup[filtered 4 lines of output] P01 INFO: backup file /var/lib/postgresql/9.4/demo/global/pg_control (8KB, 97%) checksum a95486fe557497cce188290436c39eb4bd91e459 P01 INFO: backup file /var/lib/postgresql/9.4/demo/backup_label (236B, 100%) checksum 44e7fce402f6311d4dfa179c6b4b6e0e652aa539
P00 INFO: diff backup size = 8.2KB
P00 INFO: execute exclusive pg_stop_backup() and wait for all WAL segments to archive
P00 INFO: backup stop archive = 000000010000000000000003, lsn = 0/30000F0
[filtered 4 lines of output]#m h dom mon dow command 30 06 * * 0 pgbackrest --type=full --stanza=demo backup 30 06 * * 1-6 pgbackrest --type=diff --stanza=demo backup
sudo -u postgres pgbackrest info
stanza: demo
status: ok
db (current)
wal archive min/max (9.4-1): 000000010000000000000002 / 000000010000000000000003
full backup: 20180705-225153F
timestamp start/stop: 2018-07-05 22:51:53 / 2018-07-05 22:52:05
wal start/stop: 000000010000000000000002 / 000000010000000000000002
database size: 19.2MB, backup size: 19.2MB
repository size: 2.2MB, repository backup size: 2.2MB
diff backup: 20180705-225153F_20180705-225205D
timestamp start/stop: 2018-07-05 22:52:05 / 2018-07-05 22:52:09
wal start/stop: 000000010000000000000003 / 000000010000000000000003
database size: 19.2MB, backup size: 8.2KB
repository size: 2.2MB, repository backup size: 400B
backup reference list: 20180705-225153Fsudo pg_ctlcluster 9.4 demo stop
sudo -u postgres rm /var/lib/postgresql/9.4/demo/global/pg_control
sudo pg_ctlcluster 9.4 demo start
The PostgreSQL server failed to start. Please check the log output:
postgres: could not find the database system
Expected to find it in the directory "/var/lib/postgresql/9.4/demo", but could not open file "/var/lib/postgresql/9.4/demo/global/pg_control": No such file or directory
sudo -u postgres find /var/lib/postgresql/9.4/demo -mindepth 1 -delete
sudo -u postgres pgbackrest --stanza=demo restore
sudo pg_ctlcluster 9.4 demo start
sudo -u postgres pgbackrest --stanza=demo --type=incr \
--log-level-console=info backupP00 INFO: backup command begin 2.04: --log-level-console=info --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/9.4/demo --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-full=2 --stanza=demo --type=incr P00 INFO: last backup label = 20180705-225153F_20180705-225205D, version = 2.04
P00 INFO: execute exclusive pg_start_backup() with label "pgBackRest backup started at 2018-07-05 22:52:29": backup begins after the next regular checkpoint completes
P00 INFO: backup start archive = 000000020000000000000005, lsn = 0/5000028
P01 INFO: backup file /var/lib/postgresql/9.4/demo/pg_multixact/offsets/0000 (8KB, 33%) checksum 0631457264ff7f8d5fb1edc2c0211992a67c73e6
[filtered 10 lines of output]sudo -u postgres pgbackrest --stanza=demo --type=incr \
--log-level-console=info backupP00 INFO: backup command begin 2.04: --log-level-console=info --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/9.4/demo --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-full=2 --stanza=demo --start-fast --type=incr P00 INFO: last backup label = 20180705-225153F_20180705-225229I, version = 2.04
P00 INFO: execute exclusive pg_start_backup() with label "pgBackRest backup started at 2018-07-05 22:52:33": backup begins after the requested immediate checkpoint completes
P00 INFO: backup start archive = 000000020000000000000006, lsn = 0/6000028
P01 INFO: backup file /var/lib/postgresql/9.4/demo/global/pg_control (8KB, 97%) checksum 87c1bb85a3d66b3bc494cc0bf8927017b5702dce
[filtered 8 lines of output]sudo chmod 550 /var/lib/pgbackrest/backup/demo/
sudo -u postgres pgbackrest --stanza=demo --type=incr \
--log-level-console=info backup[filtered 2 lines of output] P00 INFO: execute exclusive pg_start_backup() with label "pgBackRest backup started at 2018-07-05 22:52:37": backup begins after the requested immediate checkpoint completes P00 INFO: backup start archive = 000000020000000000000007, lsn = 0/7000028
P00 ERROR: [047]: unable to create path '/var/lib/pgbackrest/backup/demo/20180705-225153F_20180705-225237I': Permission denied
P00 INFO: backup command end: aborted with exception [047]
sudo chmod 750 /var/lib/pgbackrest/backup/demo/
sudo -u postgres pgbackrest --stanza=demo --type=incr \
--log-level-console=info backupP00 INFO: backup command begin 2.04: --log-level-console=info --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/9.4/demo --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-full=2 --stanza=demo --start-fast --type=incr P00 INFO: last backup label = 20180705-225153F_20180705-225233I, version = 2.04 P00 INFO: execute exclusive pg_start_backup() with label "pgBackRest backup started at 2018-07-05 22:52:39": backup begins after the requested immediate checkpoint completes
P00 ERROR: [057]: ERROR: a backup is already in progress
HINT: Run pg_stop_backup() and try again.:
select to_char(current_timestamp, 'YYYY-MM-DD HH24:MI:SS.US TZ'), pg_xlogfile_name(lsn), lsn::text from pg_start_backup('pgBackRest backup started at 2018-07-05 22:52:39', true) as lsnsudo -u postgres pgbackrest --stanza=demo --type=incr \
--log-level-console=info backupP00 INFO: backup command begin 2.04: --log-level-console=info --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/9.4/demo --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-full=2 --stanza=demo --start-fast --stop-auto --type=incr P00 INFO: last backup label = 20180705-225153F_20180705-225233I, version = 2.04
P00 WARN: the cluster is already in backup mode but no pgBackRest backup process is running. pg_stop_backup() will be called so a new backup can be started.
P00 INFO: execute exclusive pg_stop_backup() and wait for all WAL segments to archive
P00 INFO: execute exclusive pg_start_backup() with label "pgBackRest backup started at 2018-07-05 22:52:41": backup begins after the requested immediate checkpoint completes
P00 INFO: backup start archive = 000000020000000000000008, lsn = 0/8000028
P01 INFO: backup file /var/lib/postgresql/9.4/demo/global/pg_control (8KB, 97%) checksum b4d5802f728e3050262d96b3b0abbd8038081bf9
[filtered 8 lines of output]sudo -u postgres pgbackrest --output=json info
[
{
"archive" : [
{
"database" : {
"id" : 1
},
"id" : "9.4-1",
"max" : "000000020000000000000008",
"min" : "000000010000000000000002"
}
],
"backup" : [
{
"archive" : {
"start" : "000000010000000000000002",
"stop" : "000000010000000000000002"
},
"backrest" : {
"format" : 5,
"version" : "2.04"
},
"database" : {
"id" : 1
},
"info" : {
"delta" : 20162900,
"repository" : {
"delta" : 2389328,
"size" : 2389328
},
"size" : 20162900
},
"label" : "20180705-225153F",
"prior" : null,
"reference" : null,
"timestamp" : {
"start" : 1530831113,
"stop" : 1530831125
},
"type" : "full"
},
{
"archive" : {
"start" : "000000010000000000000003",
"stop" : "000000010000000000000003"
},
"backrest" : {
"format" : 5,
"version" : "2.04"
},
"database" : {
"id" : 1
},
"info" : {
"delta" : 8428,
"repository" : {
"delta" : 400,
"size" : 2389328
},
"size" : 20162900
},
"label" : "20180705-225153F_20180705-225205D",
"prior" : "20180705-225153F",
"reference" : [
"20180705-225153F"
],
"timestamp" : {
"start" : 1530831125,
"stop" : 1530831129
},
"type" : "diff"
},
{
"archive" : {
"start" : "000000020000000000000005",
"stop" : "000000020000000000000005"
},
"backrest" : {
"format" : 5,
"version" : "2.04"
},
"database" : {
"id" : 1
},
"info" : {
"delta" : 24812,
"repository" : {
"delta" : 544,
"size" : 2389328
},
"size" : 20162900
},
"label" : "20180705-225153F_20180705-225229I",
"prior" : "20180705-225153F_20180705-225205D",
"reference" : [
"20180705-225153F"
],
"timestamp" : {
"start" : 1530831149,
"stop" : 1530831152
},
"type" : "incr"
},
{
"archive" : {
"start" : "000000020000000000000006",
"stop" : "000000020000000000000006"
},
"backrest" : {
"format" : 5,
"version" : "2.04"
},
"database" : {
"id" : 1
},
"info" : {
"delta" : 8428,
"repository" : {
"delta" : 400,
"size" : 2389328
},
"size" : 20162900
},
"label" : "20180705-225153F_20180705-225233I",
"prior" : "20180705-225153F_20180705-225229I",
"reference" : [
"20180705-225153F",
"20180705-225153F_20180705-225229I"
],
"timestamp" : {
"start" : 1530831153,
"stop" : 1530831156
},
"type" : "incr"
},
{
"archive" : {
"start" : "000000020000000000000008",
"stop" : "000000020000000000000008"
},
"backrest" : {
"format" : 5,
"version" : "2.04"
},
"database" : {
"id" : 1
},
"info" : {
"delta" : 8428,
"repository" : {
"delta" : 400,
"size" : 2389328
},
"size" : 20162900
},
"label" : "20180705-225153F_20180705-225241I",
"prior" : "20180705-225153F_20180705-225233I",
"reference" : [
"20180705-225153F",
"20180705-225153F_20180705-225229I"
],
"timestamp" : {
"start" : 1530831161,
"stop" : 1530831166
},
"type" : "incr"
}
],
"db" : [
{
"id" : 1,
"system-id" : 6574869498342206650,
"version" : "9.4"
}
],
"name" : "demo",
"status" : {
"code" : 0,
"message" : "ok"
}
}
]sudo -u postgres cat \
/var/lib/postgresql/pgbackrest/doc/example/pgsql-pgbackrest-info.sql-- An example of monitoring pgBackRest from within PostgresSQL
--
-- Use copy to export data from the pgBackRest info command into the jsonb
-- type so it can be queried directly by PostgresSQL.
-- Create monitor schema
create schema monitor;
-- Get pgBackRest info in JSON format
create function monitor.pgbackrest_info()
returns jsonb AS $$
declare
data jsonb;
begin
-- Create a temp table to hold the JSON data
create temp table temp_pgbackrest_data (data jsonb);
-- Copy data into the table directory from the pgBackRest into command
copy temp_pgbackrest_data (data)
from program
'pgbackrest --output=json info | tr ''\n'' '' ''' (format text);
select temp_pgbackrest_data.data
into data
from temp_pgbackrest_data;
drop table temp_pgbackrest_data;
return data;
end $$ language plpgsql;sudo -u postgres psql -f \
/var/lib/postgresql/pgbackrest/doc/example/pgsql-pgbackrest-info.sqlsudo -u postgres cat \
/var/lib/postgresql/pgbackrest/doc/example/pgsql-pgbackrest-query.sql-- Get last successful backup for each stanza
--
-- Requires the monitor.pgbackrest_info function.
with stanza as
(
select data->'name' as name,
data->'backup'->(
jsonb_array_length(data->'backup') - 1) as last_backup,
data->'archive'->(
jsonb_array_length(data->'archive') - 1) as current_archive
from jsonb_array_elements(monitor.pgbackrest_info()) as data
)
select name,
to_timestamp(
(last_backup->'timestamp'->>'stop')::numeric) as last_successful_backup,
current_archive->>'max' as last_archived_wal
from stanza;sudo -u postgres psql -f \
/var/lib/postgresql/pgbackrest/doc/example/pgsql-pgbackrest-query.sqlname | last_successful_backup | last_archived_wal --------+------------------------+-------------------------- "demo" | 2018-07-05 22:52:46+00 | 000000020000000000000008 (1 row)
sudo apt-get install jq
sudo -u postgres pgbackrest --output=json --stanza=demo info | \
jq '.[0] | .backup[-1] | .timestamp.stop'1530831166
sudo -u postgres pgbackrest --output=json --stanza=demo info | \
jq '.[0] | .archive[-1] | .max'"000000020000000000000008"
sudo -u postgres pgbackrest --stanza=demo --type=full \
--log-level-console=detail backup[filtered 763 lines of output] P00 INFO: backup command end: completed successfully P00 INFO: expire command begin
P00 DETAIL: archive retention on backup 20180705-225153F, archiveId = 9.4-1, start = 000000010000000000000002
P00 DETAIL: no archive to remove, archiveId = 9.4-1 P00 INFO: expire command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo --type=full \
--log-level-console=info backup[filtered 763 lines of output] P00 INFO: backup command end: completed successfully P00 INFO: expire command begin
P00 INFO: expire full backup set: 20180705-225153F, 20180705-225153F_20180705-225205D, 20180705-225153F_20180705-225229I, 20180705-225153F_20180705-225233I, 20180705-225153F_20180705-225241I
P00 INFO: remove expired backup 20180705-225153F_20180705-225241I
P00 INFO: remove expired backup 20180705-225153F_20180705-225233I
[filtered 3 lines of output]rollingset of differentials for the last day or more. This allows quick restores to recent points-in-time but reduces overall space consumption.
sudo -u postgres pgbackrest --stanza=demo --type=diff backup
sudo -u postgres pgbackrest --stanza=demo --type=incr backup
sudo -u postgres pgbackrest --stanza=demo --type=diff \
--log-level-console=info backup[filtered 11 lines of output] P00 INFO: backup command end: completed successfully P00 INFO: expire command begin
P00 INFO: expire diff backup set: 20180705-225303F_20180705-225316D, 20180705-225303F_20180705-225320I
P00 INFO: remove expired backup 20180705-225303F_20180705-225320I P00 INFO: remove expired backup 20180705-225303F_20180705-225316D
sudo -u postgres pgbackrest --stanza=demo --type=diff \
--log-level-console=info backup[filtered 8 lines of output] P00 INFO: execute exclusive pg_stop_backup() and wait for all WAL segments to archive P00 INFO: backup stop archive = 000000020000000000000013, lsn = 0/130000F0
P00 INFO: new backup label = 20180705-225303F_20180705-225329D
P00 INFO: backup command end: completed successfully P00 INFO: expire command begin
sudo -u postgres pgbackrest --stanza=demo --log-level-console=detail \
--repo1-retention-archive-type=diff --repo1-retention-archive=1 expireP00 INFO: expire command begin 2.04: --log-level-console=detail --log-level-stderr=off --no-log-timestamp --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-archive=1 --repo1-retention-archive-type=diff --repo1-retention-diff=2 --repo1-retention-full=2 --stanza=demo P00 DETAIL: archive retention on backup 20180705-225251F, archiveId = 9.4-1, start = 00000002000000000000000A, stop = 00000002000000000000000A P00 DETAIL: archive retention on backup 20180705-225303F, archiveId = 9.4-1, start = 00000002000000000000000B, stop = 00000002000000000000000B
P00 DETAIL: archive retention on backup 20180705-225303F_20180705-225323D, archiveId = 9.4-1, start = 00000002000000000000000F, stop = 00000002000000000000000F
P00 DETAIL: archive retention on backup 20180705-225303F_20180705-225329D, archiveId = 9.4-1, start = 000000020000000000000013
P00 DETAIL: remove archive: archiveId = 9.4-1, start = 00000002000000000000000C, stop = 00000002000000000000000E P00 DETAIL: remove archive: archiveId = 9.4-1, start = 000000020000000000000010, stop = 000000020000000000000012
P00 INFO: expire command end: completed successfully
sudo pg_ctlcluster 9.4 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta \
--log-level-console=detail restore[filtered 693 lines of output] P01 DETAIL: restore file /var/lib/postgresql/9.4/demo/base/12134/PG_VERSION - exists and matches backup (4B, 99%) checksum 8dbabb96e032b8d9f1993c0e4b9141e71ade01a1 P01 DETAIL: restore file /var/lib/postgresql/9.4/demo/base/1/PG_VERSION - exists and matches backup (4B, 99%) checksum 8dbabb96e032b8d9f1993c0e4b9141e71ade01a1
P01 DETAIL: restore file /var/lib/postgresql/9.4/demo/PG_VERSION - exists and matches backup (4B, 100%) checksum 8dbabb96e032b8d9f1993c0e4b9141e71ade01a1
P01 DETAIL: restore file /var/lib/postgresql/9.4/demo/global/12086 - exists and is zero size (0B, 100%)
P01 DETAIL: restore file /var/lib/postgresql/9.4/demo/global/12038 - exists and is zero size (0B, 100%)
[filtered 83 lines of output]
P01 DETAIL: restore file /var/lib/postgresql/9.4/demo/base/1/11885 - exists and is zero size (0B, 100%)
P00 INFO: write /var/lib/postgresql/9.4/demo/recovery.confP00 INFO: restore global/pg_control (performed last to ensure aborted restores cannot be started)
P00 INFO: restore command end: completed successfully
sudo pg_ctlcluster 9.4 demo start
sudo -u postgres psql -c "create database test1;"
CREATE DATABASE
sudo -u postgres psql -c "create database test2;"
CREATE DATABASE
sudo -u postgres pgbackrest --stanza=demo --type=incr backup
sudo -u postgres psql -c "create table test1_table (id int); \
insert into test1_table (id) values (1);" test1INSERT 0 1
sudo -u postgres psql -c "create table test2_table (id int); \
insert into test2_table (id) values (2);" test2INSERT 0 1
sudo -u postgres du -sh /var/lib/postgresql/9.4/demo/base/24576
6.4M /var/lib/postgresql/9.4/demo/base/24576
sudo pg_ctlcluster 9.4 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta \
--db-include=test2 restoresudo pg_ctlcluster 9.4 demo start
sudo -u postgres psql -c "select * from test2_table;" test2
id ---- 2 (1 row)
sudo -u postgres psql -c "select * from test1_table;" test1
psql: FATAL: relation mapping file "base/24576/pg_filenode.map" contains invalid data
sudo -u postgres du -sh /var/lib/postgresql/9.4/demo/base/24576
152K /var/lib/postgresql/9.4/demo/base/24576
sudo -u postgres psql -c "drop database test1;"
DROP DATABASE
sudo -u postgres psql -c "select oid, datname from pg_database order by oid;"
oid | datname
-------+-----------
1 | template1
12134 | template0
12139 | postgres24577 | test2
(4 rows)
sudo -u postgres pgbackrest --stanza=demo --type=diff backup
sudo -u postgres psql -c "begin; \
create table important_table (message text); \
insert into important_table values ('Important Data'); \
commit; \
select * from important_table;"message ----------------
Important Data
(1 row)
sudo -u postgres psql -Atc "select current_timestamp"
2018-07-05 22:54:08.978379+00
sudo -u postgres psql -c "begin; \
drop table important_table; \
commit; \
select * from important_table;"ERROR: relation "important_table" does not exist
LINE 1: ...le important_table; commit; select * from important_...
^sudo pg_ctlcluster 9.4 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta \
--type=time "--target=2018-07-05 22:54:08.978379+00" restoresudo -u postgres cat /var/lib/postgresql/9.4/demo/recovery.conf
restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'
recovery_target_time = '2018-07-05 22:54:08.978379+00'
sudo pg_ctlcluster 9.4 demo start
sudo -u postgres psql -c "select * from important_table"
message ----------------
Important Data
(1 row)
sudo -u postgres cat /var/log/postgresql/postgresql-9.4-demo.log
LOG: database system was interrupted; last known up at 2018-07-05 22:54:02 UTC
LOG: starting point-in-time recovery to 2018-07-05 22:54:08.978379+00
LOG: restored log file "00000004.history" from archive
LOG: restored log file "000000040000000000000018" from archive
[filtered 2 lines of output]
LOG: incomplete startup packet
LOG: restored log file "000000040000000000000019" from archiveLOG: recovery stopping before commit of transaction 689, time 2018-07-05 22:54:09.193234+00
LOG: redo done at 0/19016E48
LOG: last completed transaction was at log time 2018-07-05 22:54:08.773689+00
LOG: selected new timeline ID: 5
LOG: restored log file "00000004.history" from archive
[filtered 5 lines of output]sudo -u postgres psql -c "begin; \
drop table important_table; \
commit; \
select * from important_table;"ERROR: relation "important_table" does not exist
LINE 1: ...le important_table; commit; select * from important_...
^sudo -u postgres pgbackrest --stanza=demo --type=incr backup
sudo pg_ctlcluster 9.4 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta \
--type=time "--target=2018-07-05 22:54:08.978379+00" restoresudo pg_ctlcluster 9.4 demo start
sudo -u postgres psql -c "select * from important_table"
ERROR: relation "important_table" does not exist
LINE 1: select * from important_table
^recovery stopping before...and
last completed transaction...log messages. If they are not present then the recovery to the specified point-in-time was not successful.
sudo -u postgres cat /var/log/postgresql/postgresql-9.4-demo.log
LOG: database system was interrupted; last known up at 2018-07-05 22:54:20 UTC
LOG: starting point-in-time recovery to 2018-07-05 22:54:08.978379+00
LOG: restored log file "00000005.history" from archive LOG: restored log file "00000005000000000000001A" from archive LOG: redo starts at 0/1A000028
LOG: consistent recovery state reached at 0/1A0000F0
LOG: redo done at 0/1A0000F0
LOG: incomplete startup packet
[filtered 10 lines of output]sudo -u postgres pgbackrest info
stanza: demo
status: ok
db (current)
wal archive min/max (9.4-1): 00000002000000000000000A / 00000005000000000000001A
full backup: 20180705-225251F
timestamp start/stop: 2018-07-05 22:52:51 / 2018-07-05 22:53:03
wal start/stop: 00000002000000000000000A / 00000002000000000000000A
database size: 19.2MB, backup size: 19.2MB
repository size: 2.2MB, repository backup size: 2.2MB
full backup: 20180705-225303F
timestamp start/stop: 2018-07-05 22:53:03 / 2018-07-05 22:53:14
wal start/stop: 00000002000000000000000B / 00000002000000000000000B
database size: 19.2MB, backup size: 19.2MB
repository size: 2.2MB, repository backup size: 2.2MB
diff backup: 20180705-225303F_20180705-225329D
timestamp start/stop: 2018-07-05 22:53:29 / 2018-07-05 22:53:32
wal start/stop: 000000020000000000000013 / 000000020000000000000013
database size: 19.2MB, backup size: 72.2KB
repository size: 2.2MB, repository backup size: 9.8KB
backup reference list: 20180705-225303F
incr backup: 20180705-225303F_20180705-225342I
timestamp start/stop: 2018-07-05 22:53:42 / 2018-07-05 22:53:50
wal start/stop: 000000030000000000000015 / 000000030000000000000015
database size: 31.7MB, backup size: 12.5MB
repository size: 3.7MB, repository backup size: 1.5MB
backup reference list: 20180705-225303F, 20180705-225303F_20180705-225329D
diff backup: 20180705-225303F_20180705-225401D
timestamp start/stop: 2018-07-05 22:54:01 / 2018-07-05 22:54:08
wal start/stop: 000000040000000000000018 / 000000040000000000000018
database size: 25.5MB, backup size: 6.3MB
repository size: 3MB, repository backup size: 781.1KB
backup reference list: 20180705-225303F
incr backup: 20180705-225303F_20180705-225419I
timestamp start/stop: 2018-07-05 22:54:19 / 2018-07-05 22:54:22
wal start/stop: 00000005000000000000001A / 00000005000000000000001A
database size: 25.5MB, backup size: 1.7MB
repository size: 3MB, repository backup size: 201.5KBbackup reference list: 20180705-225303F, 20180705-225303F_20180705-225401D
sudo pg_ctlcluster 9.4 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta \
--type=time "--target=2018-07-05 22:54:08.978379+00" \
--set=20180705-225303F_20180705-225401D restoresudo pg_ctlcluster 9.4 demo start
sudo -u postgres psql -c "select * from important_table"
message ----------------
Important Data
(1 row)
recovery stopping before...and
last completed transaction...messages showing that the recovery was successful.
sudo -u postgres cat /var/log/postgresql/postgresql-9.4-demo.log
LOG: database system was interrupted; last known up at 2018-07-05 22:54:02 UTC
LOG: starting point-in-time recovery to 2018-07-05 22:54:08.978379+00
FATAL: the database system is starting up
LOG: restored log file "00000004.history" from archive
[filtered 3 lines of output]
LOG: incomplete startup packet
LOG: restored log file "000000040000000000000019" from archiveLOG: recovery stopping before commit of transaction 689, time 2018-07-05 22:54:09.193234+00
LOG: redo done at 0/19016E48
LOG: last completed transaction was at log time 2018-07-05 22:54:08.773689+00
LOG: restored log file "00000005.history" from archive
LOG: restored log file "00000006.history" from archive
[filtered 7 lines of output]{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::demo-bucket"
],
"Condition": {
"StringEquals": {
"s3:prefix": [
"",
"demo-repo"
],
"s3:delimiter": [
"/"
]
}
}
},
{
"Effect": "Allow",
"Action": [
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::demo-bucket"
],
"Condition": {
"StringLike": {
"s3:prefix": [
"demo-repo/*"
]
}
}
},
{
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:DeleteObject"
],
"Resource": [
"arn:aws:s3:::demo-bucket/demo-repo/*"
]
}
]
}sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stanza-create
P00 INFO: stanza-create command begin 2.04: --log-level-console=info --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/9.4/demo --repo1-cipher-type=none --repo1-path=/demo-repo --repo1-s3-bucket=demo-bucket --repo1-s3-endpoint=s3.amazonaws.com --repo1-s3-key=--repo1-s3-key-secret= --repo1-s3-region=us-east-1 --no-repo1-s3-verify-ssl --repo1-type=s3 --stanza=demo
P00 INFO: stanza-create command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo \
--log-level-console=info backupP00 INFO: backup command begin 2.04: --log-level-console=info --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/9.4/demo --process-max=4 --repo1-cipher-type=none --repo1-path=/demo-repo --repo1-retention-diff=2 --repo1-retention-full=2 --repo1-s3-bucket=demo-bucket --repo1-s3-endpoint=s3.amazonaws.com --repo1-s3-key=--repo1-s3-key-secret= --repo1-s3-region=us-east-1 --no-repo1-s3-verify-ssl --repo1-type=s3 --stanza=demo --start-fast --stop-auto
P00 WARN: no prior backup exists, incr backup has been changed to full
P00 INFO: execute exclusive pg_start_backup() with label "pgBackRest backup started at 2018-07-05 22:54:44": backup begins after the requested immediate checkpoint completes
P00 INFO: backup start archive = 00000007000000000000001A, lsn = 0/1A000028
[filtered 995 lines of output]
P02 INFO: backup file /var/lib/postgresql/9.4/demo/base/1/11895 (0B, 100%)
P04 INFO: backup file /var/lib/postgresql/9.4/demo/base/1/11885 (0B, 100%)P00 INFO: full backup size = 25.5MB
P00 INFO: execute exclusive pg_stop_backup() and wait for all WAL segments to archive
P00 INFO: backup stop archive = 00000007000000000000001A, lsn = 0/1A000128
[filtered 4 lines of output]sudo pg_ctlcluster 9.4 demo stop
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stop
P00 INFO: stop command begin 2.04: --log-level-console=info --log-level-stderr=off --no-log-timestamp --repo1-cipher-type=none --repo1-path=/demo-repo --repo1-s3-bucket=demo-bucket --repo1-s3-endpoint=s3.amazonaws.com --repo1-s3-key=--repo1-s3-key-secret= --repo1-s3-region=us-east-1 --no-repo1-s3-verify-ssl --repo1-type=s3 --stanza=demo
P00 INFO: stop command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stanza-delete
P00 INFO: stanza-delete command begin 2.04: --log-level-console=info --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/9.4/demo --repo1-cipher-type=none --repo1-path=/demo-repo --repo1-s3-bucket=demo-bucket --repo1-s3-endpoint=s3.amazonaws.com --repo1-s3-key=--repo1-s3-key-secret= --repo1-s3-region=us-east-1 --no-repo1-s3-verify-ssl --repo1-type=s3 --stanza=demo
P00 INFO: stanza-delete command end: completed successfully
sudo adduser --disabled-password --gecos "" pgbackrest
sudo scp build:/root/pgbackrest-release-2.04/src/pgbackrest /usr/bin
sudo chmod 755 /usr/bin/pgbackrest
sudo apt-get install libdbd-pg-perl libio-socket-ssl-perl libxml-libxml-perl
sudo mkdir -p -m 770 /var/log/pgbackrest
sudo chown pgbackrest:pgbackrest /var/log/pgbackrest
sudo mkdir -p /etc/pgbackrest
sudo mkdir -p /etc/pgbackrest/conf.d
sudo touch /etc/pgbackrest/pgbackrest.conf
sudo chmod 640 /etc/pgbackrest/pgbackrest.conf
sudo chown pgbackrest:pgbackrest /etc/pgbackrest/pgbackrest.conf
sudo mkdir -p /var/lib/pgbackrest
sudo chmod 750 /var/lib/pgbackrest
sudo chown pgbackrest:pgbackrest /var/lib/pgbackrest
sudo -u pgbackrest mkdir -m 750 /home/pgbackrest/.ssh
sudo -u pgbackrest ssh-keygen -f /home/pgbackrest/.ssh/id_rsa \
-t rsa -b 4096 -N ""sudo -u postgres mkdir -m 750 -p /var/lib/postgresql/.ssh
sudo -u postgres ssh-keygen -f /var/lib/postgresql/.ssh/id_rsa \
-t rsa -b 4096 -N ""sudo ssh root@pg-primary cat /var/lib/postgresql/.ssh/id_rsa.pub | \
sudo -u pgbackrest tee -a /home/pgbackrest/.ssh/authorized_keyssudo ssh root@repository cat /home/pgbackrest/.ssh/id_rsa.pub | \
sudo -u postgres tee -a /var/lib/postgresql/.ssh/authorized_keyssudo -u pgbackrest ssh postgres@pg-primary
sudo -u postgres ssh pgbackrest@repository
sudo -u pgbackrest pgbackrest --stanza=demo stanza-create
sudo -u postgres pgbackrest --stanza=demo check
sudo -u pgbackrest pgbackrest --stanza=demo check
sudo -u pgbackrest pgbackrest --stanza=demo backup
P00 WARN: no prior backup exists, incr backup has been changed to full
sudo pg_ctlcluster 9.4 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta restore
sudo pg_ctlcluster 9.4 demo start
sudo -u pgbackrest pgbackrest --stanza=demo backup
sudo -u pgbackrest pgbackrest --stanza=demo --type=full backup
sudo -u pgbackrest pgbackrest --stanza=demo --type=full backup
sudo -u pgbackrest pgbackrest info
stanza: demo
status: ok
db (current)
wal archive min/max (9.4-1): 000000080000000000000021 / 000000080000000000000022
full backup: 20180705-225707Ftimestamp start/stop: 2018-07-05 22:57:07 / 2018-07-05 22:57:23
wal start/stop: 000000080000000000000021 / 000000080000000000000021
database size: 25.5MB, backup size: 25.5MB
repository size: 3MB, repository backup size: 3MB
full backup: 20180705-225724Ftimestamp start/stop: 2018-07-05 22:57:24 / 2018-07-05 22:57:34
wal start/stop: 000000080000000000000022 / 000000080000000000000022
database size: 25.5MB, backup size: 25.5MB
repository size: 3MB, repository backup size: 3MBsudo -u postgres pgbackrest stop
sudo -u pgbackrest pgbackrest --stanza=demo backup
P00 ERROR: [062]: raised from remote process on 'pg-primary': stop file exists for all stanzas
sudo -u postgres pgbackrest stop
P00 WARN: stop file already exists for all stanzas
sudo -u postgres pgbackrest start
sudo -u postgres pgbackrest --stanza=demo stop
sudo -u pgbackrest pgbackrest --stanza=demo backup
P00 ERROR: [062]: raised from remote process on 'pg-primary': stop file exists for stanza demo
sudo -u postgres pgbackrest --stanza=demo start
sudo echo 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main 11' | \
sudo tee -a /etc/apt/sources.list.d/pgdg.listsudo wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
sudo apt-key add -sudo apt-get update
sudo apt-get install postgresql-common
sudo sed -i 's/^\#create\_main\_cluster.*$/create\_main\_cluster \= false/' \
/etc/postgresql-common/createcluster.confsudo apt-get install postgresql-9.4
sudo scp build:/root/pgbackrest-release-2.04/src/pgbackrest /usr/bin
sudo chmod 755 /usr/bin/pgbackrest
sudo apt-get install libdbd-pg-perl libio-socket-ssl-perl libxml-libxml-perl
sudo mkdir -p -m 770 /var/log/pgbackrest
sudo chown postgres:postgres /var/log/pgbackrest
sudo mkdir -p /etc/pgbackrest
sudo mkdir -p /etc/pgbackrest/conf.d
sudo touch /etc/pgbackrest/pgbackrest.conf
sudo chmod 640 /etc/pgbackrest/pgbackrest.conf
sudo chown postgres:postgres /etc/pgbackrest/pgbackrest.conf
sudo -u postgres mkdir -m 750 -p /var/lib/postgresql/.ssh
sudo -u postgres ssh-keygen -f /var/lib/postgresql/.ssh/id_rsa \
-t rsa -b 4096 -N ""sudo ssh root@pg-standby cat /var/lib/postgresql/.ssh/id_rsa.pub | \
sudo -u pgbackrest tee -a /home/pgbackrest/.ssh/authorized_keyssudo ssh root@repository cat /home/pgbackrest/.ssh/id_rsa.pub | \
sudo -u postgres tee -a /var/lib/postgresql/.ssh/authorized_keyssudo -u pgbackrest ssh postgres@pg-standby
sudo -u postgres ssh pgbackrest@repository
sudo pg_createcluster 9.4 demo
sudo -u postgres pgbackrest --stanza=demo --delta restore
sudo -u postgres cat /var/lib/postgresql/9.4/demo/recovery.conf
standby_mode = 'on' restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'
sudo pg_ctlcluster 9.4 demo start
sudo -u postgres cat /var/log/postgresql/postgresql-9.4-demo.log
LOG: could not bind IPv6 socket: Cannot assign requested address HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry. LOG: database system was interrupted; last known up at 2018-07-05 22:57:25 UTC
LOG: entering standby mode
LOG: restored log file "00000008.history" from archive LOG: incomplete startup packet LOG: restored log file "000000080000000000000022" from archive LOG: redo starts at 0/22000028 LOG: consistent recovery state reached at 0/22000128
LOG: database system is ready to accept read only connections
sudo -u postgres psql -c " \
begin; \
create table replicated_table (message text); \
insert into replicated_table values ('Important Data'); \
commit; \
select * from replicated_table";message ----------------
Important Data
(1 row)
sudo -u postgres psql -c "select * from replicated_table;"
ERROR: relation "replicated_table" does not exist
LINE 1: select * from replicated_table;
^sudo -u postgres psql -c "select *, current_timestamp from pg_switch_xlog()";
pg_switch_xlog | now ----------------+------------------------------- 0/23019A60 | 2018-07-05 22:59:16.550504+00 (1 row)
sudo -u postgres psql -c " \
select *, current_timestamp from replicated_table"message | now ----------------+-------------------------------
Important Data | 2018-07-05 22:59:18.017841+00
(1 row)
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info check
P00 INFO: check command begin 2.04: --log-level-console=info --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/9.4/demo --repo1-host=repository --stanza=demo
P00 INFO: switch xlog cannot be performed on the standby, all other checks passed successfully
P00 INFO: check command end: completed successfully
sudo -u postgres psql -c " \
create user replicator password 'jw8s0F4' replication";CREATE ROLE
sudo -u postgres sh -c 'echo \
"host replication replicator 172.17.0.6/32 md5" \
>> /etc/postgresql/9.4/demo/pg_hba.conf'sudo pg_ctlcluster 9.4 demo reload
sudo -u postgres sh -c 'echo \
"172.17.0.4:*:replication:replicator:jw8s0F4" \
>> /var/lib/postgresql/.pgpass'sudo -u postgres chmod 600 /var/lib/postgresql/.pgpass
sudo pg_ctlcluster 9.4 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta restore
sudo -u postgres cat /var/lib/postgresql/9.4/demo/recovery.conf
primary_conninfo = 'host=172.17.0.4 port=5432 user=replicator' standby_mode = 'on' restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'
sudo pg_ctlcluster 9.4 demo start
sudo -u postgres cat /var/log/postgresql/postgresql-9.4-demo.log
[filtered 9 lines of output] LOG: database system is ready to accept read only connections LOG: restored log file "000000080000000000000023" from archive
LOG: started streaming WAL from primary at 0/24000000 on timeline 8
sudo -u postgres psql -c " \
begin; \
create table stream_table (message text); \
insert into stream_table values ('Important Data'); \
commit; \
select *, current_timestamp from stream_table";message | now ----------------+-------------------------------
Important Data | 2018-07-05 22:59:30.021542+00
(1 row)
sudo -u postgres psql -c " \
select *, current_timestamp from stream_table"message | now ----------------+-------------------------------
Important Data | 2018-07-05 22:59:30.234481+00
(1 row)
sudo mkdir -p -m 750 /var/spool/pgbackrest
sudo chown postgres:postgres /var/spool/pgbackrest
sudo mkdir -p -m 750 /var/spool/pgbackrest
sudo chown postgres:postgres /var/spool/pgbackrest
sudo -u postgres psql -c "alter user replicator password 'bogus'"
ALTER ROLE
sudo pg_ctlcluster 9.4 demo restart
looking aheadto see which WAL segments are ready to be archived beyond the request that PostgreSQL is currently making via the archive_command. WAL segments are transferred to the archive directly from the pg_xlog/pg_wal directory and success is only returned by the archive_command when the WAL segment has been safely stored in the archive.
sudo -u postgres psql -c " \
select pg_create_restore_point('test async push'); select pg_switch_xlog(); \
select pg_create_restore_point('test async push'); select pg_switch_xlog(); \
select pg_create_restore_point('test async push'); select pg_switch_xlog(); \
select pg_create_restore_point('test async push'); select pg_switch_xlog(); \
select pg_create_restore_point('test async push'); select pg_switch_xlog();"sudo -u postgres pgbackrest --stanza=demo --log-level-console=info check
P00 INFO: check command begin 2.04: --log-level-console=info --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/9.4/demo --repo1-host=repository --stanza=demo
P00 INFO: WAL segment 000000080000000000000029 successfully stored in the archive at '/var/lib/pgbackrest/archive/demo/9.4-1/0000000800000000/000000080000000000000029-168f633069a4d2b7f6f847b4157f240c3768f97d.gz'
P00 INFO: check command end: completed successfully
sudo -u postgres cat /var/log/pgbackrest/demo-archive-push-async.log
-------------------PROCESS START------------------- P00 INFO: archive-push command begin 2.04: [pg_xlog/000000080000000000000024] --archive-async --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/9.4/demo --process-max=2 --repo1-host=repository --spool-path=/var/spool/pgbackrest --stanza=demo
P00 INFO: push 2 WAL file(s) to archive: 000000080000000000000024...000000080000000000000025 P01 DETAIL: pushed WAL file 000000080000000000000024 to archive P02 DETAIL: pushed WAL file 000000080000000000000025 to archive
P00 INFO: archive-push command end: completed successfully -------------------PROCESS START------------------- P00 INFO: archive-push command begin 2.04: [pg_xlog/000000080000000000000026] --archive-async --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/9.4/demo --process-max=2 --repo1-host=repository --spool-path=/var/spool/pgbackrest --stanza=demo
P00 INFO: push 3 WAL file(s) to archive: 000000080000000000000026...000000080000000000000028 P02 DETAIL: pushed WAL file 000000080000000000000027 to archive P01 DETAIL: pushed WAL file 000000080000000000000026 to archive P02 DETAIL: pushed WAL file 000000080000000000000028 to archive
P00 INFO: archive-push command end: completed successfully -------------------PROCESS START------------------- P00 INFO: archive-push command begin 2.04: [pg_xlog/000000080000000000000029] --archive-async --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/9.4/demo --process-max=2 --repo1-host=repository --spool-path=/var/spool/pgbackrest --stanza=demo
P00 INFO: push 1 WAL file(s) to archive: 000000080000000000000029 P01 DETAIL: pushed WAL file 000000080000000000000029 to archive
P00 INFO: archive-push command end: completed successfully
sudo -u postgres cat /var/log/pgbackrest/demo-archive-get-async.log
-------------------PROCESS START------------------- P00 INFO: archive-get command begin 2.04: [000000080000000000000022, 000000080000000000000023, 000000080000000000000024, 000000080000000000000025, 000000080000000000000026, 000000080000000000000027, 000000080000000000000028, 000000080000000000000029] --archive-async --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/9.4/demo --process-max=2 --repo1-host=repository --spool-path=/var/spool/pgbackrest --stanza=demo P00 INFO: get 8 WAL file(s) from archive: 000000080000000000000022...000000080000000000000029
P02 DETAIL: got WAL file 000000080000000000000023 from archive P01 DETAIL: got WAL file 000000080000000000000022 from archive
P02 DETAIL: WAL file 000000080000000000000024 not found in archive
P01 DETAIL: WAL file 000000080000000000000025 not found in archive
[filtered 33 lines of output]
P00 INFO: archive-get command begin 2.04: [000000080000000000000024, 000000080000000000000025, 000000080000000000000026, 000000080000000000000027, 000000080000000000000028, 000000080000000000000029, 00000008000000000000002A, 00000008000000000000002B] --archive-async --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/9.4/demo --process-max=2 --repo1-host=repository --spool-path=/var/spool/pgbackrest --stanza=demo
P00 INFO: get 8 WAL file(s) from archive: 000000080000000000000024...00000008000000000000002BP01 DETAIL: got WAL file 000000080000000000000024 from archive P02 DETAIL: got WAL file 000000080000000000000025 from archive P01 DETAIL: got WAL file 000000080000000000000026 from archive P02 DETAIL: got WAL file 000000080000000000000027 from archive
P02 DETAIL: WAL file 000000080000000000000029 not found in archive P02 DETAIL: WAL file 00000008000000000000002A not found in archive P02 DETAIL: WAL file 00000008000000000000002B not found in archive
P01 DETAIL: got WAL file 000000080000000000000028 from archive
P00 INFO: archive-get command end: completed successfully
[filtered 5 lines of output]
P02 DETAIL: WAL file 00000008000000000000002C not found in archive
P02 DETAIL: WAL file 00000008000000000000002D not found in archiveP01 DETAIL: got WAL file 000000080000000000000029 from archive
P00 INFO: archive-get command end: completed successfully
[filtered 24 lines of output]sudo -u postgres psql -c "alter user replicator password 'jw8s0F4'"
ALTER ROLE
sudo -u pgbackrest pgbackrest --stanza=demo --log-level-console=detail backup
[filtered 2 lines of output] P00 INFO: execute exclusive pg_start_backup() with label "pgBackRest backup started at 2018-07-05 22:59:49": backup begins after the requested immediate checkpoint completes P00 INFO: backup start archive = 00000008000000000000002B, lsn = 0/2B000028
P00 INFO: wait for replay on the standby to reach 0/2B000028 P00 INFO: replay on the standby reached 0/2B000348 P01 INFO: backup file pg-primary:/var/lib/postgresql/9.4/demo/global/pg_control (8KB, 0%) checksum 98f01d11eee0e87d7ffc9530ed6e5d12398cb205 P01 INFO: backup file pg-primary:/var/lib/postgresql/9.4/demo/backup_label (238B, 0%) checksum 07e9a8c7854fdda88ebe7779f9c8e899cf68bfc2
P04 INFO: backup file pg-standby:/var/lib/postgresql/9.4/demo/base/12139/12009 (240KB, 12%) checksum 4dbea5928adf3f8e259b8fc85181f336d346c110
P04 INFO: backup file pg-standby:/var/lib/postgresql/9.4/demo/base/12139/12010 (232KB, 24%) checksum 98aef823550f99512cb14fbdb9f6be608531161b
[filtered 35 lines of output]sudo pg_ctlcluster 9.4 demo stop
sudo apt-get install postgresql-9.5
sudo pg_ctlcluster 9.4 demo stop
sudo apt-get install postgresql-9.5
sudo -u postgres /usr/lib/postgresql/9.5/bin/initdb \
-D /var/lib/postgresql/9.5/demo -k -A peersudo pg_createcluster 9.5 demo
sudo -u postgres sh -c 'cd /var/lib/postgresql && \
/usr/lib/postgresql/9.5/bin/pg_upgrade \
--old-bindir=/usr/lib/postgresql/9.4/bin \
--new-bindir=/usr/lib/postgresql/9.5/bin \
--old-datadir=/var/lib/postgresql/9.4/demo \
--new-datadir=/var/lib/postgresql/9.5/demo \
--old-options=" -c config_file=/etc/postgresql/9.4/demo/postgresql.conf" \
--new-options=" -c config_file=/etc/postgresql/9.5/demo/postgresql.conf"'[filtered 68 lines of output] Creating script to delete old cluster ok
Upgrade Complete
----------------
Optimizer statistics are not transferred by pg_upgrade so,
[filtered 4 lines of output]sudo cp /etc/postgresql/9.4/demo/pg_hba.conf \
/etc/postgresql/9.5/demo/pg_hba.confsudo -u pgbackrest pgbackrest --stanza=demo --no-online \
--log-level-console=info stanza-upgradeP00 INFO: stanza-upgrade command begin 2.04: --no-backup-standby --log-level-console=info --log-level-stderr=off --no-log-timestamp --no-online --pg1-host=pg-primary --pg2-host=pg-standby --pg1-path=/var/lib/postgresql/9.5/demo --pg2-path=/var/lib/postgresql/9.5/demo --repo1-path=/var/lib/pgbackrest --stanza=demo
P00 INFO: stanza-upgrade command end: completed successfully
sudo pg_ctlcluster 9.5 demo start
sudo -u postgres pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file 9.4 demo 5432 down postgres /var/lib/postgresql/9.4/demo /var/log/postgresql/postgresql-9.4-demo.log 9.5 demo 5432 online postgres /var/lib/postgresql/9.5/demo /var/log/postgresql/postgresql-9.5-demo.log
sudo -u postgres pgbackrest --stanza=demo check
sudo pg_dropcluster 9.4 demo
sudo pg_dropcluster 9.4 demo
sudo pg_createcluster 9.5 demo
sudo -u pgbackrest pgbackrest --stanza=demo check
P00 WARN: [056]: raised from remote process on 'pg-standby': could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?sudo -u pgbackrest pgbackrest --stanza=demo --type=full backup
sudo -u postgres pgbackrest --stanza=demo --delta restore
sudo pg_ctlcluster 9.5 demo start
sudo -u postgres pgbackrest --stanza=demo check