mkdir -p /build
wget -q -O - \ https://github.com/pgbackrest/pgbackrest/archive/release/2.53.1.tar.gz | \ tar zx -C /build
sudo yum install make gcc postgresql12-devel openssl-devel \ libxml2-devel lz4-devel libzstd-devel bzip2-devel libyaml-devel libssh2-devel
cd /build/pgbackrest-release-2.53.1/src && ./configure && make
sudo yum install postgresql-libs libssh2
sudo scp build:/build/pgbackrest-release-2.53.1/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.53.1 - General help Usage: pgbackrest [options] [command] Commands: annotate Add or modify backup annotation. 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. server pgBackRest server. server-ping Ping pgBackRest server. 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. verify Verify contents of the repository. version Get version. Use 'pgbackrest help [command]' for more information.
sudo -u postgres /usr/pgsql-12/bin/initdb \ -D /var/lib/pgsql/12/data -k -A peer
sudo -u postgres bash -c ' \ export PGBACKREST_LOG_PATH=/path/set/by/env && \ pgbackrest --log-level-console=error help backup log-path'
pgBackRest 2.53.1 - '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 systemctl restart postgresql-12.service
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stanza-create
P00 INFO: stanza-create command begin 2.53.1: --exec-id=1141-65a6b39a --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/pgsql/12/data --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.53.1: --exec-id=1168-e7f48a7f --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/pgsql/12/data --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-6df514f6bc17c9c74be471f0960e4c705332bd4e.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.53.1: --exec-id=1238-34a5abdf --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/pgsql/12/data --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 backup start: backup begins after the requested immediate checkpoint completes P00 INFO: backup start archive = 000000010000000000000002, lsn = 0/2000028 [filtered 3 lines of output] P00 INFO: check archive for segment(s) 000000010000000000000002:000000010000000000000003 P00 INFO: new backup label = 20240819-025154F
P00 INFO: full backup size = 23.5MB, file total = 981
P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.53.1: --exec-id=1238-34a5abdf --log-level-console=info --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 7 lines of output] P00 INFO: check archive for segment(s) 000000010000000000000004:000000010000000000000005 P00 INFO: new backup label = 20240819-025154F_20240819-025159D
P00 INFO: diff backup size = 8.8KB, file total = 981
P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.53.1: --exec-id=1298-bd4af4ff --log-level-console=info --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/000000010000000000000005
full backup: 20240819-025154F
timestamp start/stop: 2024-08-19 02:51:54+00 / 2024-08-19 02:51:57+00 wal start/stop: 000000010000000000000002 / 000000010000000000000003 database size: 23.5MB, database backup size: 23.5MB repo1: backup set size: 2.8MB, backup size: 2.8MB
diff backup: 20240819-025154F_20240819-025159D
timestamp start/stop: 2024-08-19 02:51:59+00 / 2024-08-19 02:52:00+00 wal start/stop: 000000010000000000000004 / 000000010000000000000005 database size: 23.5MB, database backup size: 8.8KB repo1: backup set size: 2.8MB, backup size: 720B backup reference list: 20240819-025154F
sudo systemctl stop postgresql-12.service
sudo -u postgres rm /var/lib/pgsql/12/data/global/pg_control
sudo systemctl start postgresql-12.service
sudo systemctl status postgresql-12.service
[filtered 12 lines of output] Aug 19 02:52:01 pg-primary systemd[1]: postgresql-12.service: Main process exited, code=exited, status=2/INVALIDARGUMENT Aug 19 02:52:01 pg-primary systemd[1]: postgresql-12.service: Failed with result 'exit-code'.
Aug 19 02:52:01 pg-primary systemd[1]: Failed to start PostgreSQL 12 database server.
sudo -u postgres find /var/lib/pgsql/12/data -mindepth 1 -delete
sudo -u postgres pgbackrest --stanza=demo restore
sudo systemctl start postgresql-12.service
sudo -u postgres cat \ /var/lib/pgsql/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 text); -- 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 replace(temp_pgbackrest_data.data, E'\n', '\n')::jsonb into data from temp_pgbackrest_data; drop table temp_pgbackrest_data; return data; end $$ language plpgsql;
sudo -u postgres psql -f \ /var/lib/pgsql/pgbackrest/doc/example/pgsql-pgbackrest-info.sql
sudo -u postgres cat \ /var/lib/pgsql/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/pgsql/pgbackrest/doc/example/pgsql-pgbackrest-query.sql
name | last_successful_backup | last_archived_wal --------+------------------------+-------------------------- "demo" | 2024-08-19 02:52:00+00 | 000000010000000000000005 (1 row)
sudo -u postgres pgbackrest --stanza=demo --type=full backup
sudo -u postgres find /var/lib/pgbackrest/backup/demo/latest/ -type f | wc -l
5
sudo -u postgres pgbackrest --stanza=demo --annotation=source="demo backup" \ --annotation=key=value --type=full backup
sudo -u postgres pgbackrest --stanza=demo --set=20240819-025211F info
stanza: demo status: ok cipher: aes-256-cbc db (current) wal archive min/max (12): 000000020000000000000007/000000020000000000000009 full backup: 20240819-025211F timestamp start/stop: 2024-08-19 02:52:11+00 / 2024-08-19 02:52:14+00 wal start/stop: 000000020000000000000008 / 000000020000000000000009 lsn start/stop: 0/8000028 / 0/9000050 database size: 23.5MB, database backup size: 23.5MB repo1: backup size: 2.8MB database list: postgres (13396)
annotation(s)
key: value source: demo backup
sudo -u postgres pgbackrest --stanza=demo --set=20240819-025211F \ --annotation=key= --annotation=new_key=new_value annotate
sudo -u postgres pgbackrest --stanza=demo --set=20240819-025211F info
stanza: demo status: ok cipher: aes-256-cbc db (current) wal archive min/max (12): 000000020000000000000007/000000020000000000000009 full backup: 20240819-025211F timestamp start/stop: 2024-08-19 02:52:11+00 / 2024-08-19 02:52:14+00 wal start/stop: 000000020000000000000008 / 000000020000000000000009 lsn start/stop: 0/8000028 / 0/9000050 database size: 23.5MB, database backup size: 23.5MB repo1: backup size: 2.8MB database list: postgres (13396)
annotation(s)
new_key: new_value source: demo backup
sudo -u postgres pgbackrest --stanza=demo --type=full \ --log-level-console=detail backup
[filtered 993 lines of output] P00 INFO: repo1: remove expired backup 20240819-025207F P00 DETAIL: repo1: 12-1 archive retention on backup 20240819-025211F, start = 000000020000000000000008
P00 INFO: repo1: 12-1 remove archive, start = 000000020000000000000007, stop = 000000020000000000000007
P00 INFO: expire command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo --type=full \ --log-level-console=info backup
[filtered 11 lines of output] P00 INFO: repo1: expire full backup 20240819-025211F P00 INFO: repo1: remove expired backup 20240819-025211F
P00 INFO: repo1: 12-1 remove archive, start = 000000020000000000000008, stop = 000000020000000000000009
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 10 lines of output] P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.53.1: --exec-id=2304-918266c4 --log-level-console=info --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 20240819-025220F_20240819-025224D, 20240819-025220F_20240819-025226I
P00 INFO: repo1: remove expired backup 20240819-025220F_20240819-025226I P00 INFO: repo1: remove expired backup 20240819-025220F_20240819-025224D P00 INFO: expire command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo --type=diff \ --log-level-console=info backup
[filtered 6 lines of output] P00 INFO: backup stop archive = 000000020000000000000017, lsn = 0/17000088 P00 INFO: check archive for segment(s) 000000020000000000000016:000000020000000000000017
P00 INFO: new backup label = 20240819-025220F_20240819-025232D
P00 INFO: diff backup size = 10.9KB, file total = 981 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.53.1: --exec-id=2494-96a78996 --log-level-console=detail --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 20240819-025216F, start = 00000002000000000000000A, stop = 00000002000000000000000B P00 DETAIL: repo1: 12-1 archive retention on backup 20240819-025220F, start = 00000002000000000000000C, stop = 00000002000000000000000D
P00 DETAIL: repo1: 12-1 archive retention on backup 20240819-025220F_20240819-025229D, start = 000000020000000000000012, stop = 000000020000000000000013
P00 DETAIL: repo1: 12-1 archive retention on backup 20240819-025220F_20240819-025232D, start = 000000020000000000000016
P00 INFO: repo1: 12-1 remove archive, start = 00000002000000000000000E, stop = 000000020000000000000011 P00 INFO: repo1: 12-1 remove archive, start = 000000020000000000000014, stop = 000000020000000000000015
P00 INFO: expire command end: completed successfully
sudo systemctl stop postgresql-12.service
sudo -u postgres pgbackrest --stanza=demo --delta \ --log-level-console=detail restore
[filtered 2 lines of output] P00 DETAIL: check '/var/lib/pgsql/12/data' 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/pgsql/12/data'
P00 DETAIL: remove invalid file '/var/lib/pgsql/12/data/backup_label.old' P00 DETAIL: remove invalid file '/var/lib/pgsql/12/data/base/13396/pg_internal.init' [filtered 1027 lines of output]
sudo systemctl start postgresql-12.service
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/pgsql/12/data/base/32768
7.8M /var/lib/pgsql/12/data/base/32768
sudo -u postgres pgbackrest --stanza=demo \ --set=20240819-025220F_20240819-025239I info
[filtered 12 lines of output] repo1: backup size: 1.9MB backup reference list: 20240819-025220F, 20240819-025220F_20240819-025232D
database list: postgres (13396), test1 (32768), test2 (32769)
sudo systemctl stop postgresql-12.service
sudo -u postgres pgbackrest --stanza=demo --delta \ --db-include=test2 --type=immediate --target-action=promote restore
sudo systemctl start postgresql-12.service
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: FATAL: relation mapping file "base/32768/pg_filenode.map" contains invalid data
sudo -u postgres du -sh /var/lib/pgsql/12/data/base/32768
16K /var/lib/pgsql/12/data/base/32768
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 13395 | template0 13396 | postgres
32769 | test2
(4 rows)
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"
2024-08-19 02:52:47.788947+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 -u postgres pgbackrest --stanza=demo --type=incr backup
sudo -u postgres pgbackrest info
[filtered 38 lines of output] backup reference list: 20240819-025220F, 20240819-025220F_20240819-025232D
incr backup: 20240819-025220F_20240819-025249I
timestamp start/stop: 2024-08-19 02:52:49+00 / 2024-08-19 02:52:51+00 wal start/stop: 00000004000000000000001A / 00000004000000000000001A [filtered 2 lines of output]
sudo systemctl stop postgresql-12.service
sudo -u postgres pgbackrest --stanza=demo --delta \ --set=20240819-025220F_20240819-025249I --target-timeline=current \ --type=time "--target=2024-08-19 02:52:47.788947+00" --target-action=promote restore
sudo systemctl start postgresql-12.service
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/lib/pgsql/12/data/log/postgresql.log
LOG: database system was interrupted; last known up at 2024-08-19 02:52:50 UTC
LOG: starting point-in-time recovery to 2024-08-19 02:52:47.788947+00
LOG: restored log file "00000004.history" from archive LOG: restored log file "00000004000000000000001A" from archive LOG: redo starts at 0/1A000028
LOG: consistent recovery state reached at 0/1A000100
LOG: database system is ready to accept read only connections LOG: redo done at 0/1A000100 [filtered 6 lines of output]
sudo systemctl stop postgresql-12.service
sudo -u postgres pgbackrest --stanza=demo --delta \ --type=time "--target=2024-08-19 02:52:47.788947+00" \ --target-action=promote restore
sudo -u postgres cat /var/lib/pgsql/12/data/postgresql.auto.conf
[filtered 9 lines of output] # Recovery settings generated by pgBackRest restore on 2024-08-19 02:52:56 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'
recovery_target_time = '2024-08-19 02:52:47.788947+00'
recovery_target_action = 'promote'
sudo systemctl start postgresql-12.service
sudo -u postgres psql -c "select * from important_table"
message ----------------
Important Data
(1 row)
sudo -u postgres cat /var/lib/pgsql/12/data/log/postgresql.log
LOG: database system was interrupted; last known up at 2024-08-19 02:52:39 UTC LOG: restored log file "00000004.history" from archive LOG: restored log file "00000005.history" from archive
LOG: starting point-in-time recovery to 2024-08-19 02:52:47.788947+00
LOG: restored log file "00000005.history" from archive LOG: restored log file "000000040000000000000019" from archive [filtered 3 lines of output] LOG: consistent recovery state reached at 0/19000100 LOG: database system is ready to accept read only connections
LOG: recovery stopping before commit of transaction 496, time 2024-08-19 02:52:49.162916+00
LOG: redo done at 0/1901D128
LOG: last completed transaction was at log time 2024-08-19 02:52:46.435517+00
LOG: selected new timeline ID: 6 LOG: archive recovery complete LOG: database system is ready to accept connections
sudo systemctl stop postgresql-12.service
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stop
P00 INFO: stop command begin 2.53.1: --exec-id=3848-13150477 --log-level-console=info --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.53.1: --exec-id=3874-72e3be3f --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/pgsql/12/data --repo=1 --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --stanza=demo
P00 INFO: stanza-delete command end: completed successfully
hierarchical namespaceas this will cause errors during expire.
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stanza-create
P00 INFO: stanza-create command begin 2.53.1: --exec-id=4031-9d962f14 --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/pgsql/12/data --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 --repo2-type=azure --stanza=demo P00 INFO: stanza-create for stanza 'demo' on repo1 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.53.1: --exec-id=4058-cb30d3da --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/pgsql/12/data --process-max=4 --repo=2 --repo2-azure-account=--repo2-azure-container=demo-container --repo2-azure-key= --repo1-block --repo1-bundle --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 backup start: backup begins after the requested immediate checkpoint completes P00 INFO: backup start archive = 00000006000000000000001B, lsn = 0/1B000028 [filtered 3 lines of output] P00 INFO: check archive for segment(s) 00000006000000000000001B:00000006000000000000001B P00 INFO: new backup label = 20240819-025304F
P00 INFO: full backup size = 31.1MB, file total = 1287
P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.53.1: --exec-id=4058-cb30d3da --log-level-console=info --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:PutObjectTagging", "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.53.1: --exec-id=4211-1845584d --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/pgsql/12/data --process-max=4 --repo=3 --repo2-azure-account=--repo2-azure-container=demo-container --repo2-azure-key= --repo1-block --repo1-bundle --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 backup start: backup begins after the requested immediate checkpoint completes P00 INFO: backup start archive = 00000006000000000000001C, lsn = 0/1C000028 [filtered 3 lines of output] P00 INFO: check archive for segment(s) 00000006000000000000001C:00000006000000000000001D P00 INFO: new backup label = 20240819-025315F
P00 INFO: full backup size = 31.1MB, file total = 1287
P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.53.1: --exec-id=4211-1845584d --log-level-console=info --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 -u postgres mkdir -m 750 -p /var/lib/pgsql/.ssh
sudo -u postgres ssh-keygen -f /var/lib/pgsql/.ssh/id_rsa_sftp \ -t rsa -b 4096 -N "" -m PEM
sudo -u pgbackrest mkdir -m 750 -p /home/pgbackrest/.ssh
(sudo ssh root@pg-primary cat /var/lib/pgsql/.ssh/id_rsa_sftp.pub) | \ sudo -u pgbackrest tee -a /home/pgbackrest/.ssh/authorized_keys
strict
ssh-keyscan -H sftp-server >> /var/lib/pgsql/.ssh/known_hosts 2>/dev/null
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stanza-create
[filtered 6 lines of output] P00 INFO: stanza 'demo' already exists on repo3 and is valid P00 INFO: stanza-create for stanza 'demo' on repo4
P00 INFO: stanza-create command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo --repo=4 \ --log-level-console=info backup
P00 INFO: backup command begin 2.53.1: --exec-id=4428-35215083 --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/pgsql/12/data --process-max=4 --repo=4 --repo2-azure-account=--repo2-azure-container=demo-container --repo2-azure-key= --repo1-block --repo1-bundle --repo4-bundle --repo1-cipher-pass= --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo3-path=/demo-repo --repo4-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 --repo4-sftp-host=sftp-server --repo4-sftp-host-key-hash-type=sha1 --repo4-sftp-host-user=pgbackrest --repo4-sftp-private-key-file=/var/lib/pgsql/.ssh/id_rsa_sftp --repo4-sftp-public-key-file=/var/lib/pgsql/.ssh/id_rsa_sftp.pub --repo2-type=azure --repo3-type=s3 --repo4-type=sftp --stanza=demo --start-fast P00 WARN: option 'repo4-retention-full' is not set for 'repo4-retention-full-type=count', the repository may run out of space HINT: to retain full backups indefinitely (without warning), set option 'repo4-retention-full' to the maximum.
P00 WARN: no prior backup exists, incr backup has been changed to full
P00 INFO: execute non-exclusive backup start: backup begins after the requested immediate checkpoint completes P00 INFO: backup start archive = 00000006000000000000001E, lsn = 0/1E000028 [filtered 3 lines of output] P00 INFO: check archive for segment(s) 00000006000000000000001E:00000006000000000000001F P00 INFO: new backup label = 20240819-025327F
P00 INFO: full backup size = 31.1MB, file total = 1287
P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.53.1: --exec-id=4428-35215083 --log-level-console=info --no-log-timestamp --repo=4 --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 --repo4-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 --repo4-sftp-host=sftp-server --repo4-sftp-host-key-hash-type=sha1 --repo4-sftp-host-user=pgbackrest --repo4-sftp-private-key-file=/var/lib/pgsql/.ssh/id_rsa_sftp --repo4-sftp-public-key-file=/var/lib/pgsql/.ssh/id_rsa_sftp.pub --repo2-type=azure --repo3-type=s3 --repo4-type=sftp --stanza=demo P00 INFO: expire command end: completed successfully
sudo groupadd pgbackrest
sudo adduser -gpgbackrest -n pgbackrest
sudo yum install postgresql-libs libssh2
sudo scp build:/build/pgbackrest-release-2.53.1/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 cat /etc/systemd/system/pgbackrest.service
[Unit] Description=pgBackRest Server After=network.target StartLimitIntervalSec=0 [Service] Type=simple Restart=always RestartSec=1 User=pgbackrest ExecStart=/usr/bin/pgbackrest server ExecStartPost=/bin/sleep 3 ExecStartPost=/bin/bash -c "[ ! -z $MAINPID ]" ExecReload=/bin/kill -HUP $MAINPID [Install] WantedBy=multi-user.target
sudo systemctl enable pgbackrest
sudo systemctl start pgbackrest
sudo cat /etc/systemd/system/pgbackrest.service
[Unit] Description=pgBackRest Server After=network.target StartLimitIntervalSec=0 [Service] Type=simple Restart=always RestartSec=1 User=postgres ExecStart=/usr/bin/pgbackrest server ExecStartPost=/bin/sleep 3 ExecStartPost=/bin/bash -c "[ ! -z $MAINPID ]" ExecReload=/bin/kill -HUP $MAINPID [Install] WantedBy=multi-user.target
sudo systemctl enable pgbackrest
sudo systemctl start pgbackrest
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 systemctl stop postgresql-12.service
sudo -u postgres pgbackrest --stanza=demo --delta restore
sudo systemctl start postgresql-12.service
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): 000000070000000000000025/000000070000000000000027 full backup: 20240819-025437F
timestamp start/stop: 2024-08-19 02:54:37+00 / 2024-08-19 02:54:41+00
wal start/stop: 000000070000000000000025 / 000000070000000000000025 database size: 31.1MB, database backup size: 31.1MB repo1: backup set size: 3.7MB, backup size: 3.7MB full backup: 20240819-025443F
timestamp start/stop: 2024-08-19 02:54:43+00 / 2024-08-19 02:54:46+00
wal start/stop: 000000070000000000000026 / 000000070000000000000027 database size: 31.1MB, database backup size: 31.1MB 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 pg1: [StopError] raised from remote-0 tls protocol on 'pg-primary': stop file exists for all stanzas
P00 ERROR: [056]: unable to find primary cluster - cannot proceed HINT: are all available clusters in recovery?
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 pg1: [StopError] raised from remote-0 tls protocol on 'pg-primary': stop file exists for stanza demo
P00 ERROR: [056]: unable to find primary cluster - cannot proceed HINT: are all available clusters in recovery?
sudo -u postgres pgbackrest --stanza=demo start
sudo yum install postgresql-libs libssh2
sudo scp build:/build/pgbackrest-release-2.53.1/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 cat /etc/systemd/system/pgbackrest.service
[Unit] Description=pgBackRest Server After=network.target StartLimitIntervalSec=0 [Service] Type=simple Restart=always RestartSec=1 User=postgres ExecStart=/usr/bin/pgbackrest server ExecStartPost=/bin/sleep 3 ExecStartPost=/bin/bash -c "[ ! -z $MAINPID ]" ExecReload=/bin/kill -HUP $MAINPID [Install] WantedBy=multi-user.target
sudo systemctl enable pgbackrest
sudo systemctl start pgbackrest
sudo -u postgres mkdir -p -m 700 /var/lib/pgsql/12/data
sudo -u postgres pgbackrest --stanza=demo --type=standby restore
sudo -u postgres cat /var/lib/pgsql/12/data/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 2024-08-19 02:52:02 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-08-19 02:52:34 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-08-19 02:52:56 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Removed by pgBackRest restore on 2024-08-19 02:54:33 # recovery_target_time = '2024-08-19 02:52:47.788947+00' # Removed by pgBackRest restore on 2024-08-19 02:54:33 # recovery_target_action = 'promote' # Recovery settings generated by pgBackRest restore on 2024-08-19 02:54:33 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-08-19 02:55:31 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'
sudo systemctl start postgresql-12.service
sudo -u postgres cat /var/lib/pgsql/12/data/log/postgresql.log
LOG: database system was interrupted; last known up at 2024-08-19 02:54:43 UTC
LOG: entering standby mode
LOG: restored log file "00000007.history" from archive LOG: restored log file "000000070000000000000026" from archive LOG: redo starts at 0/26000028 LOG: restored log file "000000070000000000000027" from archive LOG: consistent recovery state reached at 0/27000050
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/28021810 | 2024-08-19 02:55:36.266072+00 (1 row)
sudo -u postgres psql -c " \ select *, current_timestamp from replicated_table"
message | current_timestamp ----------------+-------------------------------
Important Data | 2024-08-19 02:55:38.414788+00
(1 row)
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info check
P00 INFO: check command begin 2.53.1: --exec-id=1285-02de4fa3 --log-level-console=info --log-level-file=detail --no-log-timestamp --pg1-path=/var/lib/pgsql/12/data --repo1-host=repository --repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt --repo1-host-cert-file=/etc/pgbackrest/cert/client.crt --repo1-host-key-file=/etc/pgbackrest/cert/client.key --repo1-host-type=tls --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.8/32 md5" \ >> /var/lib/pgsql/12/data/pg_hba.conf'
sudo systemctl reload postgresql-12.service
sudo -u postgres sh -c 'echo \ "172.17.0.6:*:replication:replicator:jw8s0F4" \ >> /var/lib/pgsql/.pgpass'
sudo -u postgres chmod 600 /var/lib/pgsql/.pgpass
sudo systemctl stop postgresql-12.service
sudo -u postgres pgbackrest --stanza=demo --delta --type=standby restore
sudo -u postgres cat /var/lib/pgsql/12/data/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 2024-08-19 02:52:02 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-08-19 02:52:34 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-08-19 02:52:56 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Removed by pgBackRest restore on 2024-08-19 02:54:33 # recovery_target_time = '2024-08-19 02:52:47.788947+00' # Removed by pgBackRest restore on 2024-08-19 02:54:33 # recovery_target_action = 'promote' # Recovery settings generated by pgBackRest restore on 2024-08-19 02:54:33 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-08-19 02:55:41 primary_conninfo = 'host=172.17.0.6 port=5432 user=replicator' restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'
sudo systemctl start postgresql-12.service
sudo -u postgres cat /var/lib/pgsql/12/data/log/postgresql.log
[filtered 7 lines of output] LOG: database system is ready to accept read only connections LOG: restored log file "000000070000000000000028" from archive
LOG: started streaming WAL from primary at 0/29000000 on timeline 7
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 | 2024-08-19 02:55:45.68971+00
(1 row)
sudo -u postgres psql -c " \ select *, current_timestamp from stream_table"
message | current_timestamp ----------------+-------------------------------
Important Data | 2024-08-19 02:55:46.044642+00
(1 row)
sudo yum install postgresql-libs libssh2
sudo scp build:/build/pgbackrest-release-2.53.1/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 cat /etc/systemd/system/pgbackrest.service
[Unit] Description=pgBackRest Server After=network.target StartLimitIntervalSec=0 [Service] Type=simple Restart=always RestartSec=1 User=postgres ExecStart=/usr/bin/pgbackrest server ExecStartPost=/bin/sleep 3 ExecStartPost=/bin/bash -c "[ ! -z $MAINPID ]" ExecReload=/bin/kill -HUP $MAINPID [Install] WantedBy=multi-user.target
sudo systemctl enable pgbackrest
sudo systemctl start pgbackrest
sudo -u postgres /usr/pgsql-12/bin/initdb \ -D /var/lib/pgsql/12/data -k -A peer
sudo systemctl restart postgresql-12.service
sudo -u postgres pgbackrest --stanza=demo-alt --log-level-console=info stanza-create
P00 INFO: stanza-create command begin 2.53.1: --exec-id=967-b82f47f3 --log-level-console=info --log-level-file=detail --no-log-timestamp --pg1-path=/var/lib/pgsql/12/data --repo1-host=repository --repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt --repo1-host-cert-file=/etc/pgbackrest/cert/client.crt --repo1-host-key-file=/etc/pgbackrest/cert/client.key --repo1-host-type=tls --stanza=demo-alt P00 INFO: stanza-create for stanza 'demo-alt' on repo1
P00 INFO: stanza-create command end: completed successfully
sudo -u postgres pgbackrest --log-level-console=info check
P00 INFO: check command begin 2.53.1: --exec-id=994-4f8b773d --log-level-console=info --log-level-file=detail --no-log-timestamp --repo1-host=repository --repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt --repo1-host-cert-file=/etc/pgbackrest/cert/client.crt --repo1-host-key-file=/etc/pgbackrest/cert/client.key --repo1-host-type=tls
P00 INFO: check stanza 'demo-alt'
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-alt/12-1/0000000100000000/000000010000000000000001-09d34672294b39140962d5088dff8e00d3b38e37.gz' on repo1
P00 INFO: check command end: completed successfully
sudo -u pgbackrest pgbackrest --log-level-console=info check
P00 INFO: check command begin 2.53.1: --exec-id=1342-ab650ebf --log-level-console=info --no-log-timestamp --repo1-path=/var/lib/pgbackrest
P00 INFO: check stanza 'demo'
P00 INFO: check repo1 configuration (primary) P00 INFO: check repo1 archive for WAL (primary)
P00 INFO: WAL segment 000000070000000000000029 successfully archived to '/var/lib/pgbackrest/archive/demo/12-1/0000000700000000/000000070000000000000029-e2df9ea2cf3763ae0d7fa2fc42a9324f100de4c4.gz' on repo1 P00 INFO: check stanza 'demo-alt'
P00 INFO: check repo1 configuration (primary) P00 INFO: check repo1 archive for WAL (primary)
P00 INFO: WAL segment 000000010000000000000002 successfully archived to '/var/lib/pgbackrest/archive/demo-alt/12-1/0000000100000000/000000010000000000000002-a42a19376a4d8591156e530f3ded0e7d33ed7cd4.gz' on repo1
P00 INFO: check command end: completed successfully
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 systemctl restart postgresql-12.service
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.53.1: --exec-id=5455-c2677a7d --log-level-console=info --log-level-file=detail --no-log-timestamp --pg1-path=/var/lib/pgsql/12/data --repo1-host=repository --repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt --repo1-host-cert-file=/etc/pgbackrest/cert/client.crt --repo1-host-key-file=/etc/pgbackrest/cert/client.key --repo1-host-type=tls --stanza=demo P00 INFO: check repo1 configuration (primary) P00 INFO: check repo1 archive for WAL (primary)
P00 INFO: WAL segment 00000007000000000000002F successfully archived to '/var/lib/pgbackrest/archive/demo/12-1/0000000700000000/00000007000000000000002F-fd3bae85a1a05c3c0e5d222418ef7b85147d6530.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.53.1: [/var/lib/pgsql/12/data/pg_wal] --archive-async --exec-id=5425-7f8b0909 --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/pgsql/12/data --process-max=2 --repo1-host=repository --repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt --repo1-host-cert-file=/etc/pgbackrest/cert/client.crt --repo1-host-key-file=/etc/pgbackrest/cert/client.key --repo1-host-type=tls --spool-path=/var/spool/pgbackrest --stanza=demo
P00 INFO: push 1 WAL file(s) to archive: 00000007000000000000002A P01 DETAIL: pushed WAL file '00000007000000000000002A' to the archive
P00 DETAIL: statistics: {"socket.client":{"total":1},"socket.session":{"total":1},"tls.client":{"total":1},"tls.session":{"total":1}} P00 INFO: archive-push:async command end: completed successfully -------------------PROCESS START------------------- P00 INFO: archive-push:async command begin 2.53.1: [/var/lib/pgsql/12/data/pg_wal] --archive-async --exec-id=5457-929ad567 --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/pgsql/12/data --process-max=2 --repo1-host=repository --repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt --repo1-host-cert-file=/etc/pgbackrest/cert/client.crt --repo1-host-key-file=/etc/pgbackrest/cert/client.key --repo1-host-type=tls --spool-path=/var/spool/pgbackrest --stanza=demo
P00 INFO: push 4 WAL file(s) to archive: 00000007000000000000002B...00000007000000000000002E P01 DETAIL: pushed WAL file '00000007000000000000002B' to the archive P02 DETAIL: pushed WAL file '00000007000000000000002C' to the archive P01 DETAIL: pushed WAL file '00000007000000000000002D' to the archive P02 DETAIL: pushed WAL file '00000007000000000000002E' to the archive
P00 DETAIL: statistics: {"socket.client":{"total":1},"socket.session":{"total":1},"tls.client":{"total":1},"tls.session":{"total":1}} P00 INFO: archive-push:async command end: completed successfully -------------------PROCESS START------------------- P00 INFO: archive-push:async command begin 2.53.1: [/var/lib/pgsql/12/data/pg_wal] --archive-async --exec-id=5465-53feed03 --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/pgsql/12/data --process-max=2 --repo1-host=repository --repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt --repo1-host-cert-file=/etc/pgbackrest/cert/client.crt --repo1-host-key-file=/etc/pgbackrest/cert/client.key --repo1-host-type=tls --spool-path=/var/spool/pgbackrest --stanza=demo
P00 INFO: push 1 WAL file(s) to archive: 00000007000000000000002F P01 DETAIL: pushed WAL file '00000007000000000000002F' to the archive
P00 DETAIL: statistics: {"socket.client":{"total":1},"socket.session":{"total":1},"tls.client":{"total":1},"tls.session":{"total":1}} 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.53.1: [000000070000000000000026, 000000070000000000000027, 000000070000000000000028, 000000070000000000000029, 00000007000000000000002A, 00000007000000000000002B, 00000007000000000000002C, 00000007000000000000002D] --archive-async --exec-id=1823-c8e19b40 --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/pgsql/12/data --process-max=2 --repo1-host=repository --repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt --repo1-host-cert-file=/etc/pgbackrest/cert/client.crt --repo1-host-key-file=/etc/pgbackrest/cert/client.key --repo1-host-type=tls --spool-path=/var/spool/pgbackrest --stanza=demo P00 INFO: get 8 WAL file(s) from archive: 000000070000000000000026...00000007000000000000002D
P01 DETAIL: found 000000070000000000000026 in the repo1: 12-1 archive P02 DETAIL: found 000000070000000000000027 in the repo1: 12-1 archive P01 DETAIL: found 000000070000000000000028 in the repo1: 12-1 archive P02 DETAIL: found 000000070000000000000029 in the repo1: 12-1 archive
P00 DETAIL: unable to find 00000007000000000000002A in the archive P00 DETAIL: statistics: {"socket.client":{"total":1},"socket.session":{"total":1},"tls.client":{"total":1},"tls.session":{"total":1}} [filtered 24 lines of output] P00 INFO: archive-get:async command begin 2.53.1: [00000007000000000000002A, 00000007000000000000002B, 00000007000000000000002C, 00000007000000000000002D, 00000007000000000000002E, 00000007000000000000002F, 000000070000000000000030, 000000070000000000000031] --archive-async --exec-id=1879-a4561461 --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/pgsql/12/data --process-max=2 --repo1-host=repository --repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt --repo1-host-cert-file=/etc/pgbackrest/cert/client.crt --repo1-host-key-file=/etc/pgbackrest/cert/client.key --repo1-host-type=tls --spool-path=/var/spool/pgbackrest --stanza=demo P00 INFO: get 8 WAL file(s) from archive: 00000007000000000000002A...000000070000000000000031
P01 DETAIL: found 00000007000000000000002A in the repo1: 12-1 archive P02 DETAIL: found 00000007000000000000002B in the repo1: 12-1 archive P01 DETAIL: found 00000007000000000000002C in the repo1: 12-1 archive P02 DETAIL: found 00000007000000000000002D in the repo1: 12-1 archive P01 DETAIL: found 00000007000000000000002E in the repo1: 12-1 archive P02 DETAIL: found 00000007000000000000002F in the repo1: 12-1 archive
P00 DETAIL: unable to find 000000070000000000000030 in the archive P00 DETAIL: statistics: {"socket.client":{"total":1},"socket.session":{"total":1},"tls.client":{"total":1},"tls.session":{"total":1}} [filtered 14 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 backup start: backup begins after the requested immediate checkpoint completes P00 INFO: backup start archive = 000000070000000000000031, lsn = 0/31000028
P00 INFO: wait for replay on the standby to reach 0/31000028 P00 INFO: replay on the standby reached 0/31000028
P00 INFO: check archive for prior segment 000000070000000000000030
P01 DETAIL: backup file pg-primary:/var/lib/pgsql/12/data/global/pg_control (8KB, 0.34%) checksum 6963467940d8949ca5a332bf890b113d0d94f8e1
P02 DETAIL: backup file pg-standby:/var/lib/pgsql/12/data/base/13396/2608 (456KB, 19.77%) checksum fdf79152d7ad43993fd0e95f3ab99230b5456da9 P03 DETAIL: backup file pg-standby:/var/lib/pgsql/12/data/base/13396/1249 (440KB, 38.52%) checksum 80fa69c6255667377f0514d4931db96c0d023b6c P04 DETAIL: backup file pg-standby:/var/lib/pgsql/12/data/base/13396/2674 (344KB, 53.18%) checksum 82b8cc51aae38a0a0b387a92a9bb094029a58456
P01 DETAIL: backup file pg-primary:/var/lib/pgsql/12/data/log/postgresql.log (6.1KB, 53.44%) checksum 37728223f0dcc7ea217195f9c8ede32bf0b61181 P01 DETAIL: backup file pg-primary:/var/lib/pgsql/12/data/pg_hba.conf (4.5KB, 53.63%) checksum 65e54ae24bda87b2542351cb16a7fecc7e5aceeb
P01 DETAIL: match file from prior backup pg-primary:/var/lib/pgsql/12/data/current_logfiles (26B, 53.63%) checksum 78a9f5c10960f0d91fcd313937469824861795a2 P01 DETAIL: match file from prior backup pg-primary:/var/lib/pgsql/12/data/pg_logical/replorigin_checkpoint (8B, 53.63%) checksum 347fc8f2df71bd4436e38bd1516ccd7ea0d46532 [filtered 1298 lines of output]
sudo systemctl stop postgresql-12.service
sudo systemctl stop postgresql-12.service
sudo -u postgres /usr/pgsql-13/bin/initdb \ -D /var/lib/pgsql/13/data -k -A peer
sudo -u postgres sh -c 'cd /var/lib/pgsql && \ /usr/pgsql-13/bin/pg_upgrade \ --old-bindir=/usr/pgsql-12/bin \ --new-bindir=/usr/pgsql-13/bin \ --old-datadir=/var/lib/pgsql/12/data \ --new-datadir=/var/lib/pgsql/13/data \ --old-options=" -c config_file=/var/lib/pgsql/12/data/postgresql.conf" \ --new-options=" -c config_file=/var/lib/pgsql/13/data/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 /var/lib/pgsql/12/data/pg_hba.conf \ /var/lib/pgsql/13/data/pg_hba.conf
sudo -u postgres pgbackrest --stanza=demo --no-online \ --log-level-console=info stanza-upgrade
P00 INFO: stanza-upgrade command begin 2.53.1: --exec-id=5956-60543fe7 --log-level-console=info --log-level-file=detail --no-log-timestamp --no-online --pg1-path=/var/lib/pgsql/13/data --repo1-host=repository --repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt --repo1-host-cert-file=/etc/pgbackrest/cert/client.crt --repo1-host-key-file=/etc/pgbackrest/cert/client.key --repo1-host-type=tls --stanza=demo P00 INFO: stanza-upgrade for stanza 'demo' on repo1
P00 INFO: stanza-upgrade command end: completed successfully
sudo systemctl start postgresql-13.service
sudo -u postgres systemctl status postgresql-13.service
sudo -u postgres pgbackrest --stanza=demo check
sudo rm -rf /var/lib/pgsql/12/data
sudo rm -rf /var/lib/pgsql/12/data
sudo -u postgres mkdir -p -m 700 /usr/pgsql-13/bin
sudo -u pgbackrest pgbackrest --stanza=demo check
P00 WARN: unable to check pg2: [DbConnectError] raised from remote-0 tls protocol on 'pg-standby': unable to connect to 'dbname='postgres' port=5432': could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/run/postgresql/.s.PGSQL.5432"?
sudo -u pgbackrest pgbackrest --stanza=demo --type=full backup
sudo -u postgres pgbackrest --stanza=demo --type=standby restore
sudo systemctl start postgresql-13.service
sudo -u postgres pgbackrest --stanza=demo check