mkdir -p /build
wget -q -O - \ https://github.com/pgbackrest/pgbackrest/archive/release/2.36.tar.gz | \ tar zx -C /build
sudo apt-get install make gcc libpq-dev libssl-dev libxml2-dev pkg-config \ liblz4-dev libzstd-dev libbz2-dev libz-dev libyaml-dev
cd /build/pgbackrest-release-2.36/src && ./configure && make
sudo apt-get install postgresql-client libxml2
sudo scp build:/build/pgbackrest-release-2.36/src/pgbackrest /usr/bin
sudo chmod 755 /usr/bin/pgbackrest
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.36 - 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. repo-get Get a file from a repository. repo-ls List files in a repository. 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/12/bin/initdb \ -D /var/lib/postgresql/12/demo -k -A peer
sudo pg_createcluster 12 demo
Configuring already existing cluster (configuration: /etc/postgresql/12/demo, data: /var/lib/postgresql/12/demo, owner: 102:103) Ver Cluster Port Status Owner Data directory Log file 12 demo 5432 down postgres /var/lib/postgresql/12/demo /var/log/postgresql/postgresql-12-demo.log
sudo -u postgres bash -c ' \ export PGBACKREST_LOG_PATH=/path/set/by/env && \ pgbackrest --log-level-console=error help backup log-path'
pgBackRest 2.36 - 'backup' command - 'log-path' option help Path where log files are stored. The log path provides a location for pgBackRest to store log files. Note that if log-level-file=off then no log path is required.
current: /path/set/by/env
default: /var/log/pgbackrest
sudo mkdir -p /var/lib/pgbackrest
sudo chmod 750 /var/lib/pgbackrest
sudo chown postgres:postgres /var/lib/pgbackrest
sudo pg_ctlcluster 12 demo restart
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stanza-create
P00 INFO: stanza-create command begin 2.36: --exec-id=1366-f2772c57 --log-level-console=info --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --stanza=demo P00 INFO: stanza-create for stanza 'demo' on repo1
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.36: --exec-id=1377-3cf7b456 --log-level-console=info --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --stanza=demo P00 INFO: check repo1 configuration (primary) P00 INFO: check repo1 archive for WAL (primary)
P00 INFO: WAL segment 000000010000000000000001 successfully archived to '/var/lib/pgbackrest/archive/demo/12-1/0000000100000000/000000010000000000000001-121842c5b2b35528b72ba937561b957d77d6b7b1.gz' on repo1
P00 INFO: check command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo \ --log-level-console=info backup
P00 INFO: backup command begin 2.36: --exec-id=1408-368138d0 --log-level-console=info --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-full=2 --stanza=demo --start-fast
P00 WARN: no prior backup exists, incr backup has been changed to full
P00 INFO: execute non-exclusive pg_start_backup(): backup begins after the requested immediate checkpoint completes P00 INFO: backup start archive = 000000010000000000000002, lsn = 0/2000028 [filtered 2 lines of output] P00 INFO: check archive for segment(s) 000000010000000000000002:000000010000000000000002 P00 INFO: new backup label = 20211029-120551F
P00 INFO: full backup size = 23.4MB, file total = 976
P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.36: --exec-id=1408-368138d0 --log-level-console=info --log-level-stderr=off --no-log-timestamp --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-full=2 --stanza=demo
sudo -u postgres pgbackrest --stanza=demo --type=diff \ --log-level-console=info backup
[filtered 6 lines of output] P00 INFO: check archive for segment(s) 000000010000000000000003:000000010000000000000003 P00 INFO: new backup label = 20211029-120551F_20211029-120555D
P00 INFO: diff backup size = 8KB, file total = 976
P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.36: --exec-id=1437-325c4353 --log-level-console=info --log-level-stderr=off --no-log-timestamp --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-full=2 --stanza=demo
#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 cipher: aes-256-cbc db (current) wal archive min/max (12): 000000010000000000000001/000000010000000000000003
full backup: 20211029-120551F
timestamp start/stop: 2021-10-29 12:05:51 / 2021-10-29 12:05:54 wal start/stop: 000000010000000000000002 / 000000010000000000000002 database size: 23.4MB, database backup size: 23.4MB repo1: backup set size: 2.8MB, backup size: 2.8MB
diff backup: 20211029-120551F_20211029-120555D
timestamp start/stop: 2021-10-29 12:05:55 / 2021-10-29 12:05:56 wal start/stop: 000000010000000000000003 / 000000010000000000000003 database size: 23.4MB, database backup size: 8.3KB repo1: backup set size: 2.8MB, backup size: 480B backup reference list: 20211029-120551F
sudo pg_ctlcluster 12 demo stop
sudo -u postgres rm /var/lib/postgresql/12/demo/global/pg_control
sudo pg_ctlcluster 12 demo start
Error: /usr/lib/postgresql/12/bin/pg_ctl /usr/lib/postgresql/12/bin/pg_ctl start -D /var/lib/postgresql/12/demo -l /var/log/postgresql/postgresql-12-demo.log -s -o -c config_file="/etc/postgresql/12/demo/postgresql.conf" exited with status 1:
postgres: could not find the database system
Expected to find it in the directory "/var/lib/postgresql/12/demo", but could not open file "/var/lib/postgresql/12/demo/global/pg_control": No such file or directory Examine the log output.
sudo -u postgres find /var/lib/postgresql/12/demo -mindepth 1 -delete
sudo -u postgres pgbackrest --stanza=demo restore
sudo pg_ctlcluster 12 demo start
sudo -u postgres cat \ /var/lib/postgresql/pgbackrest/doc/example/pgsql-pgbackrest-info.sql
-- An example of monitoring pgBackRest from within PostgreSQL -- -- Use copy to export data from the pgBackRest info command into the jsonb -- type so it can be queried directly by PostgreSQL. -- 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 directly from the pgBackRest info command copy temp_pgbackrest_data (data) from program 'pgbackrest --output=json info' (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.sql
sudo -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.sql
name | last_successful_backup | last_archived_wal --------+------------------------+-------------------------- "demo" | 2021-10-29 12:05:56+00 | 000000010000000000000003 (1 row)
sudo apt-get install jq
sudo -u postgres pgbackrest --output=json --stanza=demo info | \ jq '.[0] | .backup[-1] | .timestamp.stop'
1635509156
sudo -u postgres pgbackrest --output=json --stanza=demo info | \ jq '.[0] | .archive[-1] | .max'
"000000010000000000000003"
sudo -u postgres pgbackrest --stanza=demo --type=full \ --log-level-console=detail backup
[filtered 984 lines of output] P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.36: --exec-id=1736-ff9ce9ad --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-full=2 --stanza=demo
P00 DETAIL: repo1: 12-1 archive retention on backup 20211029-120551F, start = 000000010000000000000002 P00 INFO: repo1: 12-1 remove archive, start = 000000010000000000000001, stop = 000000010000000000000001
P00 INFO: expire command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo --type=full \ --log-level-console=info backup
[filtered 8 lines of output] P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.36: --exec-id=1766-5c7c95b7 --log-level-console=info --log-level-stderr=off --no-log-timestamp --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-full=2 --stanza=demo
P00 INFO: repo1: expire full backup set 20211029-120551F, 20211029-120551F_20211029-120555D
P00 INFO: repo1: remove expired backup 20211029-120551F_20211029-120555D P00 INFO: repo1: remove expired backup 20211029-120551F
P00 INFO: repo1: 12-1 remove archive, start = 0000000100000000, stop = 000000020000000000000004
P00 INFO: expire command end: completed successfully
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 9 lines of output] P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.36: --exec-id=1848-52792cb8 --log-level-console=info --log-level-stderr=off --no-log-timestamp --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-diff=1 --repo1-retention-full=2 --stanza=demo
P00 INFO: repo1: expire diff backup set 20211029-120610F_20211029-120613D, 20211029-120610F_20211029-120615I
P00 INFO: repo1: remove expired backup 20211029-120610F_20211029-120615I P00 INFO: repo1: remove expired backup 20211029-120610F_20211029-120613D P00 INFO: expire command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo --type=diff \ --log-level-console=info backup
[filtered 5 lines of output] P00 INFO: backup stop archive = 00000002000000000000000D, lsn = 0/D000100 P00 INFO: check archive for segment(s) 00000002000000000000000D:00000002000000000000000D
P00 INFO: new backup label = 20211029-120610F_20211029-120620D
P00 INFO: diff backup size = 8KB, file total = 976 P00 INFO: backup command end: completed successfully [filtered 2 lines of output]
sudo -u postgres pgbackrest --stanza=demo --log-level-console=detail \ --repo1-retention-archive-type=diff --repo1-retention-archive=1 expire
P00 INFO: expire command begin 2.36: --exec-id=1939-1405cf84 --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: repo1: 12-1 archive retention on backup 20211029-120606F, start = 000000020000000000000005, stop = 000000020000000000000005 P00 DETAIL: repo1: 12-1 archive retention on backup 20211029-120610F, start = 000000020000000000000006, stop = 000000020000000000000006
P00 DETAIL: repo1: 12-1 archive retention on backup 20211029-120610F_20211029-120618D, start = 00000002000000000000000A, stop = 00000002000000000000000A
P00 DETAIL: repo1: 12-1 archive retention on backup 20211029-120610F_20211029-120620D, start = 00000002000000000000000D
P00 INFO: repo1: 12-1 remove archive, start = 000000020000000000000007, stop = 000000020000000000000009 P00 INFO: repo1: 12-1 remove archive, start = 00000002000000000000000B, stop = 00000002000000000000000C
P00 INFO: expire command end: completed successfully
sudo pg_ctlcluster 12 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta \ --log-level-console=detail restore
[filtered 2 lines of output] P00 DETAIL: check '/var/lib/postgresql/12/demo' exists P00 DETAIL: remove 'global/pg_control' so cluster will not start if restore does not complete
P00 INFO: remove invalid files/links/paths from '/var/lib/postgresql/12/demo'
P00 DETAIL: remove invalid file '/var/lib/postgresql/12/demo/backup_label.old' P00 DETAIL: remove invalid file '/var/lib/postgresql/12/demo/base/1/pg_internal.init' [filtered 815 lines of output] P01 DETAIL: restore file /var/lib/postgresql/12/demo/base/13397/PG_VERSION - exists and matches backup (3B, 99%) checksum ad552e6dc057d1d825bf49df79d6b98eba846ebe P01 DETAIL: restore file /var/lib/postgresql/12/demo/base/1/PG_VERSION - exists and matches backup (3B, 99%) checksum ad552e6dc057d1d825bf49df79d6b98eba846ebe
P01 DETAIL: restore file /var/lib/postgresql/12/demo/PG_VERSION - exists and matches backup (3B, 100%) checksum ad552e6dc057d1d825bf49df79d6b98eba846ebe
P01 DETAIL: restore file /var/lib/postgresql/12/demo/global/6100 - exists and is zero size (0B, 100%) P01 DETAIL: restore file /var/lib/postgresql/12/demo/global/6000 - exists and is zero size (0B, 100%) [filtered 202 lines of output]
sudo pg_ctlcluster 12 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 psql -c "create table test1_table (id int); \ insert into test1_table (id) values (1);" test1
INSERT 0 1
sudo -u postgres psql -c "create table test2_table (id int); \ insert into test2_table (id) values (2);" test2
INSERT 0 1
sudo -u postgres pgbackrest --stanza=demo --type=incr backup
sudo -u postgres du -sh /var/lib/postgresql/12/demo/base/24576
7.8M /var/lib/postgresql/12/demo/base/24576
sudo -u postgres pgbackrest --stanza=demo \ --set=20211029-120610F_20211029-120629I info
[filtered 11 lines of output] repo1: backup set size: 4.7MB, backup size: 1.9MB backup reference list: 20211029-120610F, 20211029-120610F_20211029-120620D
database list: postgres (13398), test1 (24576), test2 (24577)
sudo pg_ctlcluster 12 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta \ --db-include=test2 --type=immediate --target-action=promote restore
sudo pg_ctlcluster 12 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: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: relation mapping file "base/24576/pg_filenode.map" contains invalid data
sudo -u postgres du -sh /var/lib/postgresql/12/demo/base/24576
16K /var/lib/postgresql/12/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 13397 | template0 13398 | postgres
24577 | 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"
2021-10-29 12:06:41.23673+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 12 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta \ --type=time "--target=2021-10-29 12:06:41.23673+00" \ --target-action=promote restore
sudo -u postgres cat /var/lib/postgresql/12/demo/postgresql.auto.conf
[filtered 14 lines of output] # Recovery settings generated by pgBackRest restore on 2021-10-29 12:06:43 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'
recovery_target_time = '2021-10-29 12:06:41.23673+00'
recovery_target_action = 'promote'
sudo pg_ctlcluster 12 demo start
sudo -u postgres psql -c "select * from important_table"
message ----------------
Important Data
(1 row)
sudo -u postgres cat /var/log/postgresql/postgresql-12-demo.log
[filtered 3 lines of output] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" LOG: database system was interrupted; last known up at 2021-10-29 12:06:38 UTC
LOG: starting point-in-time recovery to 2021-10-29 12:06:41.23673+00
LOG: restored log file "00000004.history" from archive LOG: restored log file "000000040000000000000010" from archive [filtered 2 lines of output] LOG: database system is ready to accept read only connections LOG: restored log file "000000040000000000000011" from archive
LOG: recovery stopping before commit of transaction 495, time 2021-10-29 12:06:42.508122+00
LOG: redo done at 0/11019DD8
LOG: last completed transaction was at log time 2021-10-29 12:06:39.99863+00
LOG: selected new timeline ID: 5 LOG: archive recovery complete [filtered 2 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 -u postgres pgbackrest info
stanza: demo status: ok cipher: aes-256-cbc db (current) wal archive min/max (12): 000000020000000000000005/000000050000000000000012 full backup: 20211029-120606F timestamp start/stop: 2021-10-29 12:06:06 / 2021-10-29 12:06:09 wal start/stop: 000000020000000000000005 / 000000020000000000000005 database size: 23.4MB, database backup size: 23.4MB repo1: backup set size: 2.8MB, backup size: 2.8MB full backup: 20211029-120610F timestamp start/stop: 2021-10-29 12:06:10 / 2021-10-29 12:06:12 wal start/stop: 000000020000000000000006 / 000000020000000000000006 database size: 23.4MB, database backup size: 23.4MB repo1: backup set size: 2.8MB, backup size: 2.8MB diff backup: 20211029-120610F_20211029-120620D timestamp start/stop: 2021-10-29 12:06:20 / 2021-10-29 12:06:22 wal start/stop: 00000002000000000000000D / 00000002000000000000000D database size: 23.4MB, database backup size: 8.3KB repo1: backup set size: 2.8MB, backup size: 496B backup reference list: 20211029-120610F incr backup: 20211029-120610F_20211029-120629I timestamp start/stop: 2021-10-29 12:06:29 / 2021-10-29 12:06:30 wal start/stop: 00000003000000000000000F / 00000003000000000000000F database size: 38.7MB, database backup size: 15.8MB repo1: backup set size: 4.7MB, backup size: 1.9MB backup reference list: 20211029-120610F, 20211029-120610F_20211029-120620D diff backup: 20211029-120610F_20211029-120638D timestamp start/stop: 2021-10-29 12:06:38 / 2021-10-29 12:06:39 wal start/stop: 000000040000000000000010 / 000000040000000000000010 database size: 31MB, database backup size: 8.2MB repo1: backup set size: 3.8MB, backup size: 1011.1KB backup reference list: 20211029-120610F
incr backup: 20211029-120610F_20211029-120649I
timestamp start/stop: 2021-10-29 12:06:49 / 2021-10-29 12:06:50 wal start/stop: 000000050000000000000012 / 000000050000000000000012 database size: 31MB, database backup size: 2.2MB repo1: backup set size: 3.8MB, backup size: 234KB backup reference list: 20211029-120610F, 20211029-120610F_20211029-120638D
sudo pg_ctlcluster 12 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta \ --set=20211029-120610F_20211029-120649I \ --type=time "--target=2021-10-29 12:06:41.23673+00" --target-action=promote restore
sudo pg_ctlcluster 12 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-12-demo.log
[filtered 3 lines of output] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" LOG: database system was interrupted; last known up at 2021-10-29 12:06:49 UTC
LOG: starting point-in-time recovery to 2021-10-29 12:06:41.23673+00
LOG: restored log file "00000005.history" from archive LOG: restored log file "000000050000000000000012" from archive LOG: redo starts at 0/12000028
LOG: consistent recovery state reached at 0/12000100
LOG: database system is ready to accept read only connections LOG: redo done at 0/12000100 [filtered 7 lines of output]
sudo pg_ctlcluster 12 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta \ --type=time "--target=2021-10-29 12:06:41.23673+00" \ --target-action=promote restore
sudo pg_ctlcluster 12 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-12-demo.log
[filtered 5 lines of output] LOG: restored log file "00000005.history" from archive LOG: restored log file "00000006.history" from archive
LOG: starting point-in-time recovery to 2021-10-29 12:06:41.23673+00
LOG: restored log file "00000006.history" from archive LOG: restored log file "000000040000000000000010" from archive [filtered 4 lines of output] LOG: database system is ready to accept read only connections LOG: restored log file "000000050000000000000011" from archive
LOG: recovery stopping before commit of transaction 496, time 2021-10-29 12:06:48.410664+00
LOG: redo done at 0/11022408
LOG: last completed transaction was at log time 2021-10-29 12:06:39.99863+00
LOG: selected new timeline ID: 7 LOG: archive recovery complete [filtered 2 lines of output]
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stanza-create
[filtered 2 lines of output] P00 INFO: stanza 'demo' already exists on repo1 and is valid P00 INFO: stanza-create for stanza 'demo' on repo2
P00 INFO: stanza-create command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo --repo=2 \ --log-level-console=info backup
P00 INFO: backup command begin 2.36: --exec-id=2798-0931aac5 --log-level-console=info --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --process-max=4 --repo=2 --repo2-azure-account=--repo2-azure-container=demo-container --repo2-azure-key= --repo1-cipher-pass= --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo1-retention-diff=2 --repo1-retention-full=2 --repo2-retention-full=4 --repo2-type=azure --stanza=demo --start-fast
P00 WARN: no prior backup exists, incr backup has been changed to full
P00 INFO: execute non-exclusive pg_start_backup(): backup begins after the requested immediate checkpoint completes P00 INFO: backup start archive = 000000070000000000000012, lsn = 0/12000028 [filtered 2 lines of output] P00 INFO: check archive for segment(s) 000000070000000000000012:000000070000000000000012 P00 INFO: new backup label = 20211029-120704F
P00 INFO: full backup size = 31MB, file total = 1282
P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.36: --exec-id=2798-0931aac5 --log-level-console=info --log-level-stderr=off --no-log-timestamp --repo=2 --repo2-azure-account=--repo2-azure-container=demo-container --repo2-azure-key= --repo1-cipher-pass= --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo1-retention-diff=2 --repo1-retention-full=2 --repo2-retention-full=4 --repo2-type=azure --stanza=demo
{ "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
[filtered 4 lines of output] P00 INFO: stanza 'demo' already exists on repo2 and is valid P00 INFO: stanza-create for stanza 'demo' on repo3
P00 INFO: stanza-create command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo --repo=3 \ --log-level-console=info backup
P00 INFO: backup command begin 2.36: --exec-id=2873-6aad5a60 --log-level-console=info --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --process-max=4 --repo=3 --repo2-azure-account=--repo2-azure-container=demo-container --repo2-azure-key= --repo1-cipher-pass= --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo3-path=/demo-repo --repo1-retention-diff=2 --repo1-retention-full=2 --repo2-retention-full=4 --repo3-retention-full=4 --repo3-s3-bucket=demo-bucket --repo3-s3-endpoint=s3.us-east-1.amazonaws.com --repo3-s3-key= --repo3-s3-key-secret= --repo3-s3-region=us-east-1 --repo2-type=azure --repo3-type=s3 --stanza=demo --start-fast
P00 WARN: no prior backup exists, incr backup has been changed to full
P00 INFO: execute non-exclusive pg_start_backup(): backup begins after the requested immediate checkpoint completes P00 INFO: backup start archive = 000000070000000000000013, lsn = 0/13000028 [filtered 2 lines of output] P00 INFO: check archive for segment(s) 000000070000000000000013:000000070000000000000013 P00 INFO: new backup label = 20211029-120709F
P00 INFO: full backup size = 31MB, file total = 1282
P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.36: --exec-id=2873-6aad5a60 --log-level-console=info --log-level-stderr=off --no-log-timestamp --repo=3 --repo2-azure-account=--repo2-azure-container=demo-container --repo2-azure-key= --repo1-cipher-pass= --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo3-path=/demo-repo --repo1-retention-diff=2 --repo1-retention-full=2 --repo2-retention-full=4 --repo3-retention-full=4 --repo3-s3-bucket=demo-bucket --repo3-s3-endpoint=s3.us-east-1.amazonaws.com --repo3-s3-key= --repo3-s3-key-secret= --repo3-s3-region=us-east-1 --repo2-type=azure --repo3-type=s3 --stanza=demo
sudo pg_ctlcluster 12 demo stop
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stop
P00 INFO: stop command begin 2.36: --exec-id=2937-e18e99b9 --log-level-console=info --log-level-stderr=off --no-log-timestamp --stanza=demo
P00 INFO: stop command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo --repo=1 \ --log-level-console=info stanza-delete
P00 INFO: stanza-delete command begin 2.36: --exec-id=2947-b29fa5d9 --log-level-console=info --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --repo=1 --repo2-azure-account=--repo2-azure-container=demo-container --repo2-azure-key= --repo1-cipher-pass= --repo1-cipher-type=aes-256-cbc --repo4-gcs-bucket=demo-bucket --repo4-gcs-key= --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo3-path=/demo-repo --repo4-path=/demo-repo --repo3-s3-bucket=demo-bucket --repo3-s3-endpoint=s3.us-east-1.amazonaws.com --repo3-s3-key= --repo3-s3-key-secret= --repo3-s3-region=us-east-1 --repo2-type=azure --repo3-type=s3 --repo4-type=gcs --stanza=demo
P00 INFO: stanza-delete command end: completed successfully
sudo adduser --disabled-password --gecos "" pgbackrest
sudo apt-get install postgresql-client libxml2
sudo scp build:/build/pgbackrest-release-2.36/src/pgbackrest /usr/bin
sudo chmod 755 /usr/bin/pgbackrest
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 ""
(echo -n 'no-agent-forwarding,no-X11-forwarding,no-port-forwarding,' && \ echo -n 'command="/usr/bin/pgbackrest ${SSH_ORIGINAL_COMMAND#* }" ' && \ sudo ssh root@pg-primary cat /var/lib/postgresql/.ssh/id_rsa.pub) | \ sudo -u pgbackrest tee -a /home/pgbackrest/.ssh/authorized_keys
(echo -n 'no-agent-forwarding,no-X11-forwarding,no-port-forwarding,' && \ echo -n 'command="/usr/bin/pgbackrest ${SSH_ORIGINAL_COMMAND#* }" ' && \ sudo ssh root@repository cat /home/pgbackrest/.ssh/id_rsa.pub) | \ sudo -u postgres tee -a /var/lib/postgresql/.ssh/authorized_keys
sudo -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 12 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta restore
sudo pg_ctlcluster 12 demo start
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 cipher: none db (current) wal archive min/max (12): 00000008000000000000001A/00000008000000000000001B full backup: 20211029-120743F
timestamp start/stop: 2021-10-29 12:07:43 / 2021-10-29 12:07:46
wal start/stop: 00000008000000000000001A / 00000008000000000000001A database size: 31MB, database backup size: 31MB repo1: backup set size: 3.7MB, backup size: 3.7MB full backup: 20211029-120748F
timestamp start/stop: 2021-10-29 12:07:48 / 2021-10-29 12:07:50
wal start/stop: 00000008000000000000001B / 00000008000000000000001B database size: 31MB, database backup size: 31MB repo1: backup set size: 3.7MB, backup size: 3.7MB
sudo -u postgres pgbackrest stop
sudo -u pgbackrest pgbackrest --stanza=demo backup
P00 WARN: unable to check pg-1: [StopError] raised from remote-0 ssh protocol on 'pg-primary': stop file exists for all stanzas
P00 ERROR: [056]: unable to find primary cluster - cannot proceed
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 WARN: unable to check pg-1: [StopError] raised from remote-0 ssh protocol on 'pg-primary': stop file exists for stanza demo
P00 ERROR: [056]: unable to find primary cluster - cannot proceed
sudo -u postgres pgbackrest --stanza=demo start
sudo apt-get install postgresql-client libxml2
sudo scp build:/build/pgbackrest-release-2.36/src/pgbackrest /usr/bin
sudo chmod 755 /usr/bin/pgbackrest
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 ""
(echo -n 'no-agent-forwarding,no-X11-forwarding,no-port-forwarding,' && \ echo -n 'command="/usr/bin/pgbackrest ${SSH_ORIGINAL_COMMAND#* }" ' && \ sudo ssh root@pg-standby cat /var/lib/postgresql/.ssh/id_rsa.pub) | \ sudo -u pgbackrest tee -a /home/pgbackrest/.ssh/authorized_keys
(echo -n 'no-agent-forwarding,no-X11-forwarding,no-port-forwarding,' && \ echo -n 'command="/usr/bin/pgbackrest ${SSH_ORIGINAL_COMMAND#* }" ' && \ sudo ssh root@repository cat /home/pgbackrest/.ssh/id_rsa.pub) | \ sudo -u postgres tee -a /var/lib/postgresql/.ssh/authorized_keys
sudo -u pgbackrest ssh postgres@pg-standby
sudo -u postgres ssh pgbackrest@repository
sudo pg_createcluster 12 demo
sudo -u postgres pgbackrest --stanza=demo --delta --type=standby restore
sudo -u postgres cat /var/lib/postgresql/12/demo/postgresql.auto.conf
# Do not edit this file manually! # It will be overwritten by the ALTER SYSTEM command. # Recovery settings generated by pgBackRest restore on 2021-10-29 12:05:58 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2021-10-29 12:06:23 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2021-10-29 12:06:32 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Removed by pgBackRest restore on 2021-10-29 12:06:56 # recovery_target = 'immediate' # Removed by pgBackRest restore on 2021-10-29 12:06:56 # recovery_target_action = 'promote' # Recovery settings generated by pgBackRest restore on 2021-10-29 12:06:56 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Removed by pgBackRest restore on 2021-10-29 12:07:38 # recovery_target_time = '2021-10-29 12:06:41.23673+00' # Removed by pgBackRest restore on 2021-10-29 12:07:38 # recovery_target_action = 'promote' # Recovery settings generated by pgBackRest restore on 2021-10-29 12:07:38 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2021-10-29 12:08:01 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'
sudo pg_ctlcluster 12 demo start
sudo -u postgres cat /var/log/postgresql/postgresql-12-demo.log
[filtered 4 lines of output] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" LOG: database system was interrupted; last known up at 2021-10-29 12:07:48 UTC
LOG: entering standby mode
LOG: restored log file "00000008.history" from archive LOG: restored log file "00000008000000000000001B" from archive LOG: redo starts at 0/1B000028 LOG: consistent recovery state reached at 0/1B000100
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_wal()";
pg_switch_wal | current_timestamp ---------------+------------------------------- 0/1C021718 | 2021-10-29 12:08:07.549186+00 (1 row)
sudo -u postgres psql -c " \ select *, current_timestamp from replicated_table"
message | current_timestamp ----------------+-------------------------------
Important Data | 2021-10-29 12:08:08.414679+00
(1 row)
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info check
P00 INFO: check command begin 2.36: --exec-id=1417-21ffb037 --log-level-console=info --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --repo1-host=repository --stanza=demo P00 INFO: check repo1 (standby)
P00 INFO: switch wal not performed because this is a standby
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.7/32 md5" \ >> /etc/postgresql/12/demo/pg_hba.conf'
sudo pg_ctlcluster 12 demo reload
sudo -u postgres sh -c 'echo \ "172.17.0.5:*:replication:replicator:jw8s0F4" \ >> /var/lib/postgresql/.pgpass'
sudo -u postgres chmod 600 /var/lib/postgresql/.pgpass
sudo pg_ctlcluster 12 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta --type=standby restore
sudo -u postgres cat /var/lib/postgresql/12/demo/postgresql.auto.conf
# Do not edit this file manually! # It will be overwritten by the ALTER SYSTEM command. # Recovery settings generated by pgBackRest restore on 2021-10-29 12:05:58 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2021-10-29 12:06:23 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2021-10-29 12:06:32 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Removed by pgBackRest restore on 2021-10-29 12:06:56 # recovery_target = 'immediate' # Removed by pgBackRest restore on 2021-10-29 12:06:56 # recovery_target_action = 'promote' # Recovery settings generated by pgBackRest restore on 2021-10-29 12:06:56 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Removed by pgBackRest restore on 2021-10-29 12:07:38 # recovery_target_time = '2021-10-29 12:06:41.23673+00' # Removed by pgBackRest restore on 2021-10-29 12:07:38 # recovery_target_action = 'promote' # Recovery settings generated by pgBackRest restore on 2021-10-29 12:07:38 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2021-10-29 12:08:11 primary_conninfo = 'host=172.17.0.5 port=5432 user=replicator' restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'
sudo pg_ctlcluster 12 demo start
sudo -u postgres cat /var/log/postgresql/postgresql-12-demo.log
[filtered 11 lines of output] LOG: database system is ready to accept read only connections LOG: restored log file "00000008000000000000001C" from archive
LOG: started streaming WAL from primary at 0/1D000000 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 | current_timestamp ----------------+-------------------------------
Important Data | 2021-10-29 12:08:16.746025+00
(1 row)
sudo -u postgres psql -c " \ select *, current_timestamp from stream_table"
message | current_timestamp ----------------+------------------------------
Important Data | 2021-10-29 12:08:16.93526+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 12 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_wal(); \ select pg_create_restore_point('test async push'); select pg_switch_wal(); \ select pg_create_restore_point('test async push'); select pg_switch_wal(); \ select pg_create_restore_point('test async push'); select pg_switch_wal(); \ select pg_create_restore_point('test async push'); select pg_switch_wal();"
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info check
P00 INFO: check command begin 2.36: --exec-id=3602-14941921 --log-level-console=info --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --repo1-host=repository --stanza=demo P00 INFO: check repo1 configuration (primary) P00 INFO: check repo1 archive for WAL (primary)
P00 INFO: WAL segment 000000080000000000000022 successfully archived to '/var/lib/pgbackrest/archive/demo/12-1/0000000800000000/000000080000000000000022-256032fd13a8e92807d2fbf916d91843a34c484f.gz' on repo1
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:async command begin 2.36: [/var/lib/postgresql/12/demo/pg_wal] --archive-async --exec-id=3587-0eaf57f4 --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --process-max=2 --repo1-host=repository --spool-path=/var/spool/pgbackrest --stanza=demo
P00 INFO: push 1 WAL file(s) to archive: 00000008000000000000001D P01 DETAIL: pushed WAL file '00000008000000000000001D' to the archive
P00 INFO: archive-push:async command end: completed successfully -------------------PROCESS START------------------- P00 INFO: archive-push:async command begin 2.36: [/var/lib/postgresql/12/demo/pg_wal] --archive-async --exec-id=3605-804d267f --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --process-max=2 --repo1-host=repository --spool-path=/var/spool/pgbackrest --stanza=demo
P00 INFO: push 4 WAL file(s) to archive: 00000008000000000000001E...000000080000000000000021 P01 DETAIL: pushed WAL file '00000008000000000000001E' to the archive P02 DETAIL: pushed WAL file '00000008000000000000001F' to the archive P02 DETAIL: pushed WAL file '000000080000000000000021' to the archive P01 DETAIL: pushed WAL file '000000080000000000000020' to the archive
P00 INFO: archive-push:async command end: completed successfully -------------------PROCESS START------------------- P00 INFO: archive-push:async command begin 2.36: [/var/lib/postgresql/12/demo/pg_wal] --archive-async --exec-id=3621-7c1ac38a --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --process-max=2 --repo1-host=repository --spool-path=/var/spool/pgbackrest --stanza=demo
P00 INFO: push 1 WAL file(s) to archive: 000000080000000000000022 P01 DETAIL: pushed WAL file '000000080000000000000022' to the archive
P00 INFO: archive-push:async command end: completed successfully
sudo -u postgres cat /var/log/pgbackrest/demo-archive-get-async.log
-------------------PROCESS START------------------- P00 INFO: archive-get:async command begin 2.36: [00000008000000000000001B, 00000008000000000000001C, 00000008000000000000001D, 00000008000000000000001E, 00000008000000000000001F, 000000080000000000000020, 000000080000000000000021, 000000080000000000000022] --archive-async --exec-id=1652-36029fb1 --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --process-max=2 --repo1-host=repository --spool-path=/var/spool/pgbackrest --stanza=demo P00 INFO: get 8 WAL file(s) from archive: 00000008000000000000001B...000000080000000000000022
P02 DETAIL: found 00000008000000000000001C in the repo1: 12-1 archive P01 DETAIL: found 00000008000000000000001B in the repo1: 12-1 archive
P00 DETAIL: unable to find 00000008000000000000001D in the archive P00 INFO: archive-get:async command end: completed successfully [filtered 14 lines of output] P00 INFO: archive-get:async command begin 2.36: [00000008000000000000001D, 00000008000000000000001E, 00000008000000000000001F, 000000080000000000000020, 000000080000000000000021, 000000080000000000000022, 000000080000000000000023, 000000080000000000000024] --archive-async --exec-id=1694-87354168 --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --process-max=2 --repo1-host=repository --spool-path=/var/spool/pgbackrest --stanza=demo P00 INFO: get 8 WAL file(s) from archive: 00000008000000000000001D...000000080000000000000024
P02 DETAIL: found 00000008000000000000001E in the repo1: 12-1 archive P02 DETAIL: found 00000008000000000000001F in the repo1: 12-1 archive P01 DETAIL: found 00000008000000000000001D in the repo1: 12-1 archive P02 DETAIL: found 000000080000000000000020 in the repo1: 12-1 archive P01 DETAIL: found 000000080000000000000021 in the repo1: 12-1 archive P02 DETAIL: found 000000080000000000000022 in the repo1: 12-1 archive
P00 DETAIL: unable to find 000000080000000000000023 in the archive P00 INFO: archive-get:async command end: completed successfully [filtered 11 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 non-exclusive pg_start_backup(): backup begins after the requested immediate checkpoint completes P00 INFO: backup start archive = 000000080000000000000024, lsn = 0/24000028
P00 INFO: wait for replay on the standby to reach 0/24000028 P00 INFO: replay on the standby reached 0/24000028
P02 DETAIL: backup file pg-standby:/var/lib/postgresql/12/demo/base/13398/2608 (456KB, 19%) checksum 8a1b4147f0cd9e6232ebcf971f34a1b726af93c5 P02 DETAIL: backup file pg-standby:/var/lib/postgresql/12/demo/base/13398/2673 (280KB, 31%) checksum 13cf784264de5d300e755082fe0d91be52847cb5 [filtered 14 lines of output] P02 DETAIL: backup file pg-standby:/var/lib/postgresql/12/demo/base/13398/2679 (16KB, 62%) checksum 6405582b3965a1cc4cefa4d89a075bf392bfee62 P02 DETAIL: backup file pg-standby:/var/lib/postgresql/12/demo/base/13398/2678 (16KB, 63%) checksum f7c84518351ccdb7384c91142454a10665eb4985
P01 DETAIL: backup file pg-primary:/var/lib/postgresql/12/demo/global/pg_control (8KB, 63%) checksum 221cf7dcd1912b900bc386e092297f2b3e4b1068
P02 DETAIL: backup file pg-standby:/var/lib/postgresql/12/demo/pg_xact/0000 (8KB, 63%) checksum 32d68ad3e1925c9bfa1fff50781196c74861f1b3
P01 DETAIL: backup file pg-primary:/var/lib/postgresql/12/demo/pg_logical/replorigin_checkpoint (8B, 63%) checksum 347fc8f2df71bd4436e38bd1516ccd7ea0d46532
P03 DETAIL: backup file pg-standby:/var/lib/postgresql/12/demo/base/13398/1249 (440KB, 82%) checksum b7e359434670a0611273a3626a1feb0250243414 P04 DETAIL: backup file pg-standby:/var/lib/postgresql/12/demo/base/13398/2674 (344KB, 97%) checksum 28827539e9e6b01b680e50390c21331a0a5d0639 [filtered 1274 lines of output]
sudo pg_ctlcluster 12 demo stop
sudo pg_ctlcluster 12 demo stop
sudo -u postgres /usr/lib/postgresql/13/bin/initdb \ -D /var/lib/postgresql/13/demo -k -A peer
sudo pg_createcluster 13 demo
sudo -u postgres sh -c 'cd /var/lib/postgresql && \ /usr/lib/postgresql/13/bin/pg_upgrade \ --old-bindir=/usr/lib/postgresql/12/bin \ --new-bindir=/usr/lib/postgresql/13/bin \ --old-datadir=/var/lib/postgresql/12/demo \ --new-datadir=/var/lib/postgresql/13/demo \ --old-options=" -c config_file=/etc/postgresql/12/demo/postgresql.conf" \ --new-options=" -c config_file=/etc/postgresql/13/demo/postgresql.conf"'
[filtered 66 lines of output] Checking for extension updates ok
Upgrade Complete
---------------- Optimizer statistics are not transferred by pg_upgrade so, [filtered 4 lines of output]
sudo cp /etc/postgresql/12/demo/pg_hba.conf \ /etc/postgresql/13/demo/pg_hba.conf
sudo -u postgres pgbackrest --stanza=demo --no-online \ --log-level-console=info stanza-upgrade
P00 INFO: stanza-upgrade command begin 2.36: --exec-id=4022-d6ee7d0e --log-level-console=info --log-level-file=detail --log-level-stderr=off --no-log-timestamp --no-online --pg1-path=/var/lib/postgresql/13/demo --repo1-host=repository --stanza=demo P00 INFO: stanza-upgrade for stanza 'demo' on repo1
P00 INFO: stanza-upgrade command end: completed successfully
sudo pg_ctlcluster 13 demo start
sudo -u postgres pg_lsclusters
sudo -u postgres pgbackrest --stanza=demo check
sudo pg_dropcluster 12 demo
sudo pg_dropcluster 12 demo
sudo pg_createcluster 13 demo
sudo -u pgbackrest pgbackrest --stanza=demo check
P00 WARN: unable to check pg-2: [DbConnectError] raised from remote-0 ssh protocol on 'pg-standby': unable to connect to 'dbname='postgres' port=5432': connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory Is the server running locally and accepting connections on that socket?
sudo -u pgbackrest pgbackrest --stanza=demo --type=full backup
sudo -u postgres pgbackrest --stanza=demo --delta --type=standby restore
sudo pg_ctlcluster 13 demo start
sudo -u postgres pgbackrest --stanza=demo check