mkdir -p /build
wget -q -O - \ https://github.com/pgbackrest/pgbackrest/archive/release/2.54.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.54.1/src && ./configure && make
sudo yum install postgresql-libs libssh2
sudo scp build:/build/pgbackrest-release-2.54.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.54.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.54.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.54.1: --exec-id=1117-d92c4a02 --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.1: --exec-id=1144-eae41668 --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-81f620c88b9b64cd2b7b35410374cf4c65b7c0a4.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.1: --exec-id=1214-28d076e7 --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 = 20241216-145957F
P00 INFO: full backup size = 23.5MB, file total = 981
P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.54.1: --exec-id=1214-28d076e7 --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 = 20241216-145957F_20241216-150000D
P00 INFO: diff backup size = 8.8KB, file total = 981
P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.54.1: --exec-id=1273-8f841e66 --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: 20241216-145957F
timestamp start/stop: 2024-12-16 14:59:57+00 / 2024-12-16 15:00: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: 20241216-145957F_20241216-150000D
timestamp start/stop: 2024-12-16 15:00:00+00 / 2024-12-16 15:00:02+00 wal start/stop: 000000010000000000000004 / 000000010000000000000005 database size: 23.5MB, database backup size: 8.8KB repo1: backup set size: 2.8MB, backup size: 704B 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-12-16 15:00: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=20241216-150016F info
stanza: demo status: ok cipher: aes-256-cbc db (current) wal archive min/max (12): 000000020000000000000007/000000020000000000000009 full backup: 20241216-150016F timestamp start/stop: 2024-12-16 15:00:16+00 / 2024-12-16 15:00:18+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=20241216-150016F \ --annotation=key= --annotation=new_key=new_value annotate
sudo -u postgres pgbackrest --stanza=demo --set=20241216-150016F info
stanza: demo status: ok cipher: aes-256-cbc db (current) wal archive min/max (12): 000000020000000000000007/000000020000000000000009 full backup: 20241216-150016F timestamp start/stop: 2024-12-16 15:00:16+00 / 2024-12-16 15:00:18+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 20241216-150014F P00 DETAIL: repo1: 12-1 archive retention on backup 20241216-150016F, 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 20241216-150016F P00 INFO: repo1: remove expired backup 20241216-150016F
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.1: --exec-id=2270-20dd3df3 --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 20241216-150022F_20241216-150025D, 20241216-150022F_20241216-150026I
P00 INFO: repo1: remove expired backup 20241216-150022F_20241216-150026I P00 INFO: repo1: remove expired backup 20241216-150022F_20241216-150025D 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 = 20241216-150022F_20241216-150029D
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.54.1: --exec-id=2460-a416c0e4 --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 20241216-150020F, start = 00000002000000000000000A, stop = 00000002000000000000000B P00 DETAIL: repo1: 12-1 archive retention on backup 20241216-150022F, start = 00000002000000000000000C, stop = 00000002000000000000000D
P00 DETAIL: repo1: 12-1 archive retention on backup 20241216-150022F_20241216-150027D, start = 000000020000000000000012, stop = 000000020000000000000013
P00 DETAIL: repo1: 12-1 archive retention on backup 20241216-150022F_20241216-150029D, 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=20241216-150022F_20241216-150039I info
[filtered 12 lines of output] repo1: backup size: 1.9MB backup reference list: 20241216-150022F, 20241216-150022F_20241216-150029D
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-12-16 15:00:52.750094+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: 20241216-150022F_20241216-150054I
timestamp start/stop: 2024-12-16 15:00:54+00 / 2024-12-16 15:00:55+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=20241216-150022F_20241216-150054I --target-timeline=current \ --type=time "--target=2024-12-16 15:00:52.750094+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-12-16 15:00:54 UTC
LOG: starting point-in-time recovery to 2024-12-16 15:00:52.750094+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-12-16 15:00:52.750094+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-12-16 15:01:06 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'
recovery_target_time = '2024-12-16 15:00:52.750094+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-12-16 15:00: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-12-16 15:00:52.750094+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-12-16 15:00:54.13056+00
LOG: redo done at 0/1901D158
LOG: last completed transaction was at log time 2024-12-16 15:00:51.314158+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.1: --exec-id=3804-38654482 --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.1: --exec-id=3830-48b455fd --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.1: --exec-id=3997-b05805e9 --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.1: --exec-id=4024-84799222 --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 = 20241216-150124F
P00 INFO: full backup size = 31.1MB, file total = 1287
P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.54.1: --exec-id=4024-84799222 --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.1: --exec-id=4150-47ea97eb --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 = 20241216-150134F
P00 INFO: full backup size = 31.1MB, file total = 1287
P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.54.1: --exec-id=4150-47ea97eb --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.1: --exec-id=4387-8ebd7a9a --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 = 00000006000000000000001F, lsn = 0/1F000028 [filtered 3 lines of output] P00 INFO: check archive for segment(s) 00000006000000000000001F:00000006000000000000001F P00 INFO: new backup label = 20241216-150145F
P00 INFO: full backup size = 31.1MB, file total = 1287
P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.54.1: --exec-id=4387-8ebd7a9a --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-12-16 15:01:53 UTC] 0B STANDARD 46a151b6-0892-4488-ad8e-c91c5364f86b v3 DEL backup.info [2024-12-16 15:01:41 UTC] 1.0KiB STANDARD 76896917-6c21-45d3-8d42-537be3d6ed66 v2 PUT backup.info [2024-12-16 15:01:34 UTC] 372B STANDARD b64d4d2b-c3b3-43b4-840c-5c39a339cee8 v1 PUT backup.info
[2024-12-16 15:01:53 UTC] 0B STANDARD ddf3e518-ea1d-42e8-9c08-dfce7ac08dd2 v3 DEL backup.info.copy [2024-12-16 15:01:41 UTC] 1.0KiB STANDARD a2c96fca-d2e8-4759-ad8b-8412561ffeb2 v2 PUT backup.info.copy
sudo -u postgres pgbackrest --stanza=demo --repo=3 \ --repo-target-time="2024-12-16 15:01:42+00" info
[filtered 5 lines of output] wal archive min/max (12): 00000006000000000000001C/00000006000000000000001D
full backup: 20241216-150134F
timestamp start/stop: 2024-12-16 15:01:34+00 / 2024-12-16 15:01:41+00 wal start/stop: 00000006000000000000001C / 00000006000000000000001D repo3: backup set size: 3.7MB, backup size: 3.7MB
sudo -u postgres pgbackrest --stanza=demo --repo=3 --delta \ --repo-target-time="2024-12-16 15:01:42+00" --log-level-console=info restore
P00 INFO: restore command begin 2.54.1: --delta --exec-id=4620-d4465fdc --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-12-16 15:01:42+00" --repo2-type=azure --repo3-type=s3 --repo4-type=sftp --repo5-type=gcs --stanza=demo
P00 INFO: repo3: restore backup set 20241216-150134F, recovery will start at 2024-12-16 15:01:34
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.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): 000000080000000000000023/000000080000000000000025 full backup: 20241216-150325F
timestamp start/stop: 2024-12-16 15:03:25+00 / 2024-12-16 15:03:29+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: 20241216-150330F
timestamp start/stop: 2024-12-16 15:03:30+00 / 2024-12-16 15:03:34+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.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-12-16 15:00:07 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-12-16 15:00:33 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-12-16 15:01:06 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Removed by pgBackRest restore on 2024-12-16 15:01:56 # recovery_target_time = '2024-12-16 15:00:52.750094+00' # Removed by pgBackRest restore on 2024-12-16 15:01:56 # recovery_target_action = 'promote' # Recovery settings generated by pgBackRest restore on 2024-12-16 15:01:56 restore_command = 'pgbackrest --repo=3 --repo-target-time="2024-12-16 15:01:42+00" --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-12-16 15:03:20 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-12-16 15:04:40 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-12-16 15:03:30 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-12-16 15:04:47.767418+00 (1 row)
sudo -u postgres psql -c " \ select *, current_timestamp from replicated_table"
message | current_timestamp ----------------+-------------------------------
Important Data | 2024-12-16 15:04:49.270349+00
(1 row)
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info check
P00 INFO: check command begin 2.54.1: --exec-id=1137-dda80915 --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-12-16 15:00:07 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-12-16 15:00:33 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-12-16 15:01:06 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Removed by pgBackRest restore on 2024-12-16 15:01:56 # recovery_target_time = '2024-12-16 15:00:52.750094+00' # Removed by pgBackRest restore on 2024-12-16 15:01:56 # recovery_target_action = 'promote' # Recovery settings generated by pgBackRest restore on 2024-12-16 15:01:56 restore_command = 'pgbackrest --repo=3 --repo-target-time="2024-12-16 15:01:42+00" --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-12-16 15:03:20 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-12-16 15:04:55 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-12-16 15:05:01.21671+00
(1 row)
sudo -u postgres psql -c " \ select *, current_timestamp from stream_table"
message | current_timestamp ----------------+-------------------------------
Important Data | 2024-12-16 15:05:01.553417+00
(1 row)
sudo yum install postgresql-libs libssh2
sudo scp build:/build/pgbackrest-release-2.54.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.54.1: --exec-id=930-6374a53c --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.1: --exec-id=957-f2737514 --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-4195504148137cbd316c40e9572f24bf7e568b4c.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.1: --exec-id=1303-d9dcf57f --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-557e6ac2a23a0763aceed977c5d29c5ac6c5901a.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-586f30b130979d55df9f4849227e7c7b440e7707.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.1: --exec-id=5597-78aec58e --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-b250a420b2d941ed0ae49fe74536ffeb21f3efdb.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.1: [/var/lib/pgsql/12/data/pg_wal] --archive-async --exec-id=5561-a8f43426 --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.1: [/var/lib/pgsql/12/data/pg_wal] --archive-async --exec-id=5566-ccd30f3d --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: 000000080000000000000029...00000008000000000000002C 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
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.1: [/var/lib/pgsql/12/data/pg_wal] --archive-async --exec-id=5602-1d6640b6 --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: 00000008000000000000002D P01 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.1: [000000080000000000000024, 000000080000000000000025, 000000080000000000000026, 000000080000000000000027, 000000080000000000000028, 000000080000000000000029, 00000008000000000000002A, 00000008000000000000002B] --archive-async --exec-id=1667-d3a10719 --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 31 lines of output] P00 INFO: archive-get:async command begin 2.54.1: [000000080000000000000028, 000000080000000000000029, 00000008000000000000002A, 00000008000000000000002B, 00000008000000000000002C, 00000008000000000000002D, 00000008000000000000002E, 00000008000000000000002F] --archive-async --exec-id=1718-2519986a --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 21 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 (11KB, 0.47%) checksum 4a1c5b31cb12d9ca4e26ee03a623253a9632f344 P01 DETAIL: backup file pg-primary:/var/lib/pgsql/12/data/global/pg_control (8KB, 0.81%) checksum 68ea90f7285f83d5791a299a94dddbbcc23ff2f1 P01 DETAIL: backup file pg-primary:/var/lib/pgsql/12/data/pg_hba.conf (4.5KB, 1.00%) checksum 65e54ae24bda87b2542351cb16a7fecc7e5aceeb
P01 DETAIL: match file from prior backup pg-primary:/var/lib/pgsql/12/data/current_logfiles (26B, 1.00%) checksum 78a9f5c10960f0d91fcd313937469824861795a2 P01 DETAIL: match file from prior backup pg-primary:/var/lib/pgsql/12/data/pg_logical/replorigin_checkpoint (8B, 1.00%) 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.1: --exec-id=6086-3ed3490e --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