mkdir -p /build
wget -q -O - \ https://github.com/pgbackrest/pgbackrest/archive/release/2.54.0.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.54.0/src && ./configure && make
sudo yum install postgresql-libs libssh2
sudo scp build:/build/pgbackrest-release-2.54.0/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.54.0 - 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.54.0 - '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.54.0: --exec-id=1114-a8a71400 --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.54.0: --exec-id=1141-cb3a9a8c --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-d82f7aba24ba8d0a5d2322bb7d75d8da98375e5a.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.54.0: --exec-id=1211-59487bec --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 = 20241021-050958F
P00 INFO: full backup size = 23.5MB, file total = 981
P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.54.0: --exec-id=1211-59487bec --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 = 20241021-050958F_20241021-051000D
P00 INFO: diff backup size = 8.8KB, file total = 981
P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.54.0: --exec-id=1270-3107b814 --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: 20241021-050958F
timestamp start/stop: 2024-10-21 05:09:58+00 / 2024-10-21 05:10:00+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: 20241021-050958F_20241021-051000D
timestamp start/stop: 2024-10-21 05:10:00+00 / 2024-10-21 05:10:02+00 wal start/stop: 000000010000000000000004 / 000000010000000000000005 database size: 23.5MB, database backup size: 8.8KB repo1: backup set size: 2.8MB, backup size: 688B backup reference total: 1 full
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
postgresql-12.service - PostgreSQL 12 database server Loaded: loaded (/usr/lib/systemd/system/postgresql-12.service, disabled)
Active: failed (failed)
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-10-21 05:10:02+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=20241021-051015F info
stanza: demo status: ok cipher: aes-256-cbc db (current) wal archive min/max (12): 000000020000000000000007/000000020000000000000009 full backup: 20241021-051015F timestamp start/stop: 2024-10-21 05:10:15+00 / 2024-10-21 05:10:17+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=20241021-051015F \ --annotation=key= --annotation=new_key=new_value annotate
sudo -u postgres pgbackrest --stanza=demo --set=20241021-051015F info
stanza: demo status: ok cipher: aes-256-cbc db (current) wal archive min/max (12): 000000020000000000000007/000000020000000000000009 full backup: 20241021-051015F timestamp start/stop: 2024-10-21 05:10:15+00 / 2024-10-21 05:10:17+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 20241021-051013F P00 DETAIL: repo1: 12-1 archive retention on backup 20241021-051015F, 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 20241021-051015F P00 INFO: repo1: remove expired backup 20241021-051015F
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.54.0: --exec-id=2267-0d412f40 --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 20241021-051021F_20241021-051023D, 20241021-051021F_20241021-051024I
P00 INFO: repo1: remove expired backup 20241021-051021F_20241021-051024I P00 INFO: repo1: remove expired backup 20241021-051021F_20241021-051023D 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/17000050 P00 INFO: check archive for segment(s) 000000020000000000000016:000000020000000000000017
P00 INFO: new backup label = 20241021-051021F_20241021-051027D
P00 INFO: diff backup size = 10.8KB, 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.54.0: --exec-id=2456-ce762eb6 --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 20241021-051019F, start = 00000002000000000000000A, stop = 00000002000000000000000B P00 DETAIL: repo1: 12-1 archive retention on backup 20241021-051021F, start = 00000002000000000000000C, stop = 00000002000000000000000D
P00 DETAIL: repo1: 12-1 archive retention on backup 20241021-051021F_20241021-051025D, start = 000000020000000000000012, stop = 000000020000000000000013
P00 DETAIL: repo1: 12-1 archive retention on backup 20241021-051021F_20241021-051027D, 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=20241021-051021F_20241021-051036I info
[filtered 12 lines of output] repo1: backup size: 1.9MB backup reference list: 20241021-051021F, 20241021-051021F_20241021-051027D
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-10-21 05:10:48.907566+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 total: 1 full, 1 diff
incr backup: 20241021-051021F_20241021-051050I
timestamp start/stop: 2024-10-21 05:10:50+00 / 2024-10-21 05:10: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=20241021-051021F_20241021-051050I --target-timeline=current \ --type=time "--target=2024-10-21 05:10:48.907566+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-10-21 05:10:50 UTC
LOG: starting point-in-time recovery to 2024-10-21 05:10:48.907566+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-10-21 05:10:48.907566+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-10-21 05:11:01 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'
recovery_target_time = '2024-10-21 05:10:48.907566+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-10-21 05:10:36 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-10-21 05:10:48.907566+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-10-21 05:10:50.218097+00
LOG: redo done at 0/1901D158
LOG: last completed transaction was at log time 2024-10-21 05:10:47.605687+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.54.0: --exec-id=3799-a7bf6a2d --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.54.0: --exec-id=3825-9db0043a --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.54.0: --exec-id=3991-4b392490 --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.54.0: --exec-id=4018-a64ee246 --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 = 20241021-051117F
P00 INFO: full backup size = 31.1MB, file total = 1287
P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.54.0: --exec-id=4018-a64ee246 --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:GetObjectVersion", "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.54.0: --exec-id=4144-e53019a1 --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 = 00000006000000000000001D, lsn = 0/1D000028 [filtered 3 lines of output] P00 INFO: check archive for segment(s) 00000006000000000000001D:00000006000000000000001D P00 INFO: new backup label = 20241021-051126F
P00 INFO: full backup size = 31.1MB, file total = 1287
P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.54.0: --exec-id=4144-e53019a1 --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.54.0: --exec-id=4380-52f76aac --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 = 20241021-051133F
P00 INFO: full backup size = 31.1MB, file total = 1287
P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.54.0: --exec-id=4380-52f76aac --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 systemctl stop postgresql-12.service
sudo -u postgres pgbackrest --stanza=demo stop
sudo -u postgres pgbackrest --stanza=demo --repo=3 stanza-delete
sudo -u postgres pgbackrest --stanza=demo --repo=3 info
stanza: demo
status: error (missing stanza data)
cipher: none
mc ls --versions s3/demo-bucket/demo-repo/backup/demo/backup.info
[2024-10-21 05:11:40 UTC] 0B STANDARD 95eaa71d-8063-4600-afe1-3eb56ec1f2f7 v3 DEL backup.info [2024-10-21 05:11:31 UTC] 1.0KiB STANDARD f17b2b25-28f8-44cc-913e-83546c337648 v2 PUT backup.info [2024-10-21 05:11:25 UTC] 372B STANDARD 8c46925b-db92-439a-a2cb-5a456a0bc769 v1 PUT backup.info
[2024-10-21 05:11:40 UTC] 0B STANDARD 779ee29a-3230-4151-8643-1d1ea96f79bc v3 DEL backup.info.copy [2024-10-21 05:11:31 UTC] 1.0KiB STANDARD 475cb12d-522c-4316-a538-f503f30179ea v2 PUT backup.info.copy
sudo -u postgres pgbackrest --stanza=demo --repo=3 \ --repo-target-time="2024-10-21 05:11:31+00" info
[filtered 5 lines of output] wal archive min/max (12): 00000006000000000000001C/00000006000000000000001D
full backup: 20241021-051126F
timestamp start/stop: 2024-10-21 05:11:26+00 / 2024-10-21 05:11:30+00 wal start/stop: 00000006000000000000001D / 00000006000000000000001D repo3: backup set size: 3.7MB, backup size: 3.7MB
sudo -u postgres pgbackrest --stanza=demo --repo=3 --delta \ --repo-target-time="2024-10-21 05:11:31+00" --log-level-console=info restore
P00 INFO: restore command begin 2.54.0: --delta --exec-id=4612-702becfc --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-cipher-pass= --repo1-cipher-type=aes-256-cbc --repo5-gcs-bucket=demo-bucket --repo5-gcs-key= --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo3-path=/demo-repo --repo4-path=/demo-repo --repo5-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 --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 --repo-target-time="2024-10-21 05:11:31+00" --repo2-type=azure --repo3-type=s3 --repo4-type=sftp --repo5-type=gcs --stanza=demo
P00 INFO: repo3: restore backup set 20241021-051126F, recovery will start at 2024-10-21 05:11:26
P00 INFO: remove invalid files/links/paths from '/var/lib/pgsql/12/data' P00 INFO: write updated /var/lib/pgsql/12/data/postgresql.auto.conf [filtered 2 lines of output]
sudo systemctl start postgresql-12.service
sudo groupadd pgbackrest
sudo adduser -gpgbackrest -n pgbackrest
sudo yum install postgresql-libs libssh2
sudo scp build:/build/pgbackrest-release-2.54.0/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): 000000080000000000000023/000000080000000000000025 full backup: 20241021-051251F
timestamp start/stop: 2024-10-21 05:12:51+00 / 2024-10-21 05:12:55+00
wal start/stop: 000000080000000000000023 / 000000080000000000000023 database size: 31.1MB, database backup size: 31.1MB repo1: backup set size: 3.7MB, backup size: 3.7MB full backup: 20241021-051256F
timestamp start/stop: 2024-10-21 05:12:56+00 / 2024-10-21 05:12:59+00
wal start/stop: 000000080000000000000024 / 000000080000000000000025 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.54.0/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-10-21 05:10:07 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-10-21 05:10:31 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-10-21 05:11:01 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Removed by pgBackRest restore on 2024-10-21 05:11:43 # recovery_target_time = '2024-10-21 05:10:48.907566+00' # Removed by pgBackRest restore on 2024-10-21 05:11:43 # recovery_target_action = 'promote' # Recovery settings generated by pgBackRest restore on 2024-10-21 05:11:43 restore_command = 'pgbackrest --repo=3 --repo-target-time="2024-10-21 05:11:31+00" --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-10-21 05:12:47 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-10-21 05:13:48 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-10-21 05:12:56 UTC
LOG: entering standby mode
LOG: restored log file "00000008.history" from archive LOG: restored log file "000000080000000000000024" from archive LOG: redo starts at 0/24000028 LOG: restored log file "000000080000000000000025" from archive LOG: consistent recovery state reached at 0/25000050
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/26021840 | 2024-10-21 05:13:54.196795+00 (1 row)
sudo -u postgres psql -c " \ select *, current_timestamp from replicated_table"
message | current_timestamp ----------------+-------------------------------
Important Data | 2024-10-21 05:13:55.454868+00
(1 row)
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info check
P00 INFO: check command begin 2.54.0: --exec-id=1187-9f24d4c9 --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-10-21 05:10:07 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-10-21 05:10:31 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-10-21 05:11:01 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Removed by pgBackRest restore on 2024-10-21 05:11:43 # recovery_target_time = '2024-10-21 05:10:48.907566+00' # Removed by pgBackRest restore on 2024-10-21 05:11:43 # recovery_target_action = 'promote' # Recovery settings generated by pgBackRest restore on 2024-10-21 05:11:43 restore_command = 'pgbackrest --repo=3 --repo-target-time="2024-10-21 05:11:31+00" --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-10-21 05:12:47 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-10-21 05:14:00 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 "000000080000000000000026" from archive
LOG: started streaming WAL from primary at 0/27000000 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 | 2024-10-21 05:14:06.212656+00
(1 row)
sudo -u postgres psql -c " \ select *, current_timestamp from stream_table"
message | current_timestamp ----------------+-------------------------------
Important Data | 2024-10-21 05:14:06.515391+00
(1 row)
sudo yum install postgresql-libs libssh2
sudo scp build:/build/pgbackrest-release-2.54.0/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.54.0: --exec-id=930-9bc6ce68 --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.54.0: --exec-id=957-3684cbc9 --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-c1bea00948bde95d2d55992294fb0f6149f74621.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.54.0: --exec-id=1291-dae8135c --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 000000080000000000000027 successfully archived to '/var/lib/pgbackrest/archive/demo/12-1/0000000800000000/000000080000000000000027-f939f96dee7e1f004d8f853d5c8ffd80642718a4.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-d50fe80c45171b5d543ed448c652f9418e693be1.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.54.0: --exec-id=5579-64a79ea6 --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 00000008000000000000002D successfully archived to '/var/lib/pgbackrest/archive/demo/12-1/0000000800000000/00000008000000000000002D-f18427145348d3fa39c4a659451af3356294c267.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.54.0: [/var/lib/pgsql/12/data/pg_wal] --archive-async --exec-id=5548-4f54badb --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: 000000080000000000000028 P01 DETAIL: pushed WAL file '000000080000000000000028' 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.54.0: [/var/lib/pgsql/12/data/pg_wal] --archive-async --exec-id=5581-c8b87dc0 --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 5 WAL file(s) to archive: 000000080000000000000029...00000008000000000000002D P01 DETAIL: pushed WAL file '000000080000000000000029' to the archive P02 DETAIL: pushed WAL file '00000008000000000000002A' to the archive P02 DETAIL: pushed WAL file '00000008000000000000002C' to the archive P01 DETAIL: pushed WAL file '00000008000000000000002B' to the archive P02 DETAIL: pushed WAL file '00000008000000000000002D' 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.54.0: [000000080000000000000024, 000000080000000000000025, 000000080000000000000026, 000000080000000000000027, 000000080000000000000028, 000000080000000000000029, 00000008000000000000002A, 00000008000000000000002B] --archive-async --exec-id=1717-1368fc37 --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: 000000080000000000000024...00000008000000000000002B
P01 DETAIL: found 000000080000000000000024 in the repo1: 12-1 archive P02 DETAIL: found 000000080000000000000025 in the repo1: 12-1 archive P01 DETAIL: found 000000080000000000000026 in the repo1: 12-1 archive P02 DETAIL: found 000000080000000000000027 in the repo1: 12-1 archive
P00 DETAIL: unable to find 000000080000000000000028 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.54.0: [000000080000000000000028, 000000080000000000000029, 00000008000000000000002A, 00000008000000000000002B, 00000008000000000000002C, 00000008000000000000002D, 00000008000000000000002E, 00000008000000000000002F] --archive-async --exec-id=1766-7963598b --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: 000000080000000000000028...00000008000000000000002F
P01 DETAIL: found 000000080000000000000028 in the repo1: 12-1 archive P02 DETAIL: found 000000080000000000000029 in the repo1: 12-1 archive P01 DETAIL: found 00000008000000000000002A in the repo1: 12-1 archive P02 DETAIL: found 00000008000000000000002B in the repo1: 12-1 archive P01 DETAIL: found 00000008000000000000002C in the repo1: 12-1 archive P02 DETAIL: found 00000008000000000000002D in the repo1: 12-1 archive
P00 DETAIL: unable to find 00000008000000000000002E in the archive P00 DETAIL: statistics: {"socket.client":{"total":1},"socket.session":{"total":1},"tls.client":{"total":1},"tls.session":{"total":1}} [filtered 7 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 = 00000008000000000000002F, lsn = 0/2F000028
P00 INFO: wait for replay on the standby to reach 0/2F000028 P00 INFO: replay on the standby reached 0/2F000028
P00 INFO: check archive for prior segment 00000008000000000000002E
P01 DETAIL: backup file pg-primary:/var/lib/pgsql/12/data/log/postgresql.log (9.6KB, 0.40%) checksum ffb1a505a0eeaa9a538dc40e73cf7cd5b920c601 P01 DETAIL: backup file pg-primary:/var/lib/pgsql/12/data/global/pg_control (8KB, 0.74%) checksum 4e7be880f104c81088a3141d619049d9e04ff086 P01 DETAIL: backup file pg-primary:/var/lib/pgsql/12/data/pg_hba.conf (4.5KB, 0.93%) checksum 65e54ae24bda87b2542351cb16a7fecc7e5aceeb
P01 DETAIL: match file from prior backup pg-primary:/var/lib/pgsql/12/data/current_logfiles (26B, 0.94%) checksum 78a9f5c10960f0d91fcd313937469824861795a2 P01 DETAIL: match file from prior backup pg-primary:/var/lib/pgsql/12/data/pg_logical/replorigin_checkpoint (8B, 0.94%) checksum 347fc8f2df71bd4436e38bd1516ccd7ea0d46532 [filtered 1301 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.54.0: --exec-id=6070-bb6915f9 --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 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