mkdir -p /build
wget -q -O - \ https://github.com/pgbackrest/pgbackrest/archive/release/2.53.1.tar.gz | \ tar zx -C /build
sudo apt-get install python3-distutils meson gcc libpq-dev libssl-dev libxml2-dev \ pkg-config liblz4-dev libzstd-dev libbz2-dev libz-dev libyaml-dev libssh2-1-dev
meson setup /build/pgbackrest /build/pgbackrest-release-2.53.1
ninja -C /build/pgbackrest
sudo apt-get install postgresql-client libxml2 libssh2-1
sudo scp build:/build/pgbackrest/src/pgbackrest /usr/bin
sudo chmod 755 /usr/bin/pgbackrest
sudo mkdir -p -m 770 /var/log/pgbackrest
sudo chown postgres:postgres /var/log/pgbackrest
sudo mkdir -p /etc/pgbackrest
sudo mkdir -p /etc/pgbackrest/conf.d
sudo touch /etc/pgbackrest/pgbackrest.conf
sudo chmod 640 /etc/pgbackrest/pgbackrest.conf
sudo chown postgres:postgres /etc/pgbackrest/pgbackrest.conf
sudo -u postgres pgbackrest
pgBackRest 2.53.1 - General help Usage: pgbackrest [options] [command] Commands: annotate Add or modify backup annotation. archive-get Get a WAL segment from the archive. archive-push Push a WAL segment to the archive. backup Backup a database cluster. check Check the configuration. expire Expire backups that exceed retention. help Get help. info Retrieve information about backups. repo-get Get a file from a repository. repo-ls List files in a repository. restore Restore a database cluster. server pgBackRest server. server-ping Ping pgBackRest server. stanza-create Create the required stanza data. stanza-delete Delete a stanza. stanza-upgrade Upgrade a stanza. start Allow pgBackRest processes to run. stop Stop pgBackRest processes from running. verify Verify contents of the repository. version Get version. Use 'pgbackrest help [command]' for more information.
sudo -u postgres /usr/lib/postgresql/15/bin/initdb \ -D /var/lib/postgresql/15/demo -k -A peer
sudo pg_createcluster 15 demo
Configuring already existing cluster (configuration: /etc/postgresql/15/demo, data: /var/lib/postgresql/15/demo, owner: 102:103) Ver Cluster Port Status Owner Data directory Log file 15 demo 5432 down postgres /var/lib/postgresql/15/demo /var/log/postgresql/postgresql-15-demo.log
sudo -u postgres bash -c ' \ export PGBACKREST_LOG_PATH=/path/set/by/env && \ pgbackrest --log-level-console=error help backup log-path'
pgBackRest 2.53.1 - 'backup' command - 'log-path' option help Path where log files are stored. The log path provides a location for pgBackRest to store log files. Note that if log-level-file=off then no log path is required.
current: /path/set/by/env
default: /var/log/pgbackrest
sudo mkdir -p /var/lib/pgbackrest
sudo chmod 750 /var/lib/pgbackrest
sudo chown postgres:postgres /var/lib/pgbackrest
sudo pg_ctlcluster 15 demo restart
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stanza-create
P00 INFO: stanza-create command begin 2.53.1: --exec-id=386-1a4ade4c --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/postgresql/15/demo --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --stanza=demo P00 INFO: stanza-create for stanza 'demo' on repo1
P00 INFO: stanza-create command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info check
P00 INFO: check command begin 2.53.1: --exec-id=395-473210a6 --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/postgresql/15/demo --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --stanza=demo P00 INFO: check repo1 configuration (primary) P00 INFO: check repo1 archive for WAL (primary)
P00 INFO: WAL segment 000000010000000000000001 successfully archived to '/var/lib/pgbackrest/archive/demo/15-1/0000000100000000/000000010000000000000001-d1444ba001b68235c6bdfdf6dc7f397362130f90.gz' on repo1
P00 INFO: check command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo \ --log-level-console=info backup
P00 INFO: backup command begin 2.53.1: --exec-id=419-cd3b6f2c --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/postgresql/15/demo --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-full=2 --stanza=demo --start-fast
P00 WARN: no prior backup exists, incr backup has been changed to full
P00 INFO: execute non-exclusive backup start: backup begins after the requested immediate checkpoint completes P00 INFO: backup start archive = 000000010000000000000002, lsn = 0/2000028 [filtered 3 lines of output] P00 INFO: check archive for segment(s) 000000010000000000000002:000000010000000000000003 P00 INFO: new backup label = 20240819-030108F
P00 INFO: full backup size = 21.8MB, file total = 961
P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.53.1: --exec-id=419-cd3b6f2c --log-level-console=info --no-log-timestamp --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-full=2 --stanza=demo
sudo -u postgres pgbackrest --stanza=demo --type=diff \ --log-level-console=info backup
[filtered 7 lines of output] P00 INFO: check archive for segment(s) 000000010000000000000004:000000010000000000000005 P00 INFO: new backup label = 20240819-030108F_20240819-030112D
P00 INFO: diff backup size = 8.3KB, file total = 961
P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.53.1: --exec-id=445-c7d046cf --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 (15): 000000010000000000000001/000000010000000000000005
full backup: 20240819-030108F
timestamp start/stop: 2024-08-19 03:01:08+00 / 2024-08-19 03:01:11+00 wal start/stop: 000000010000000000000002 / 000000010000000000000003 database size: 21.8MB, database backup size: 21.8MB repo1: backup set size: 2.9MB, backup size: 2.9MB
diff backup: 20240819-030108F_20240819-030112D
timestamp start/stop: 2024-08-19 03:01:12+00 / 2024-08-19 03:01:14+00 wal start/stop: 000000010000000000000004 / 000000010000000000000005 database size: 21.8MB, database backup size: 8.3KB repo1: backup set size: 2.9MB, backup size: 448B backup reference list: 20240819-030108F
sudo pg_ctlcluster 15 demo stop
sudo -u postgres rm /var/lib/postgresql/15/demo/global/pg_control
sudo pg_ctlcluster 15 demo start
Error: /usr/lib/postgresql/15/bin/pg_ctl /usr/lib/postgresql/15/bin/pg_ctl start -D /var/lib/postgresql/15/demo -l /var/log/postgresql/postgresql-15-demo.log -s -o -c config_file="/etc/postgresql/15/demo/postgresql.conf" exited with status 1:
postgres: could not find the database system
Expected to find it in the directory "/var/lib/postgresql/15/demo", but could not open file "/var/lib/postgresql/15/demo/global/pg_control": No such file or directory Examine the log output.
sudo -u postgres find /var/lib/postgresql/15/demo -mindepth 1 -delete
sudo -u postgres pgbackrest --stanza=demo restore
sudo pg_ctlcluster 15 demo start
sudo -u postgres cat \ /var/lib/postgresql/pgbackrest/doc/example/pgsql-pgbackrest-info.sql
-- An example of monitoring pgBackRest from within PostgreSQL -- -- Use copy to export data from the pgBackRest info command into the jsonb -- type so it can be queried directly by PostgreSQL. -- Create monitor schema create schema monitor; -- Get pgBackRest info in JSON format create function monitor.pgbackrest_info() returns jsonb AS $$ declare data jsonb; begin -- Create a temp table to hold the JSON data create temp table temp_pgbackrest_data (data 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/postgresql/pgbackrest/doc/example/pgsql-pgbackrest-info.sql
sudo -u postgres cat \ /var/lib/postgresql/pgbackrest/doc/example/pgsql-pgbackrest-query.sql
-- Get last successful backup for each stanza -- -- Requires the monitor.pgbackrest_info function. with stanza as ( select data->'name' as name, data->'backup'->( jsonb_array_length(data->'backup') - 1) as last_backup, data->'archive'->( jsonb_array_length(data->'archive') - 1) as current_archive from jsonb_array_elements(monitor.pgbackrest_info()) as data ) select name, to_timestamp( (last_backup->'timestamp'->>'stop')::numeric) as last_successful_backup, current_archive->>'max' as last_archived_wal from stanza;
sudo -u postgres psql -f \ /var/lib/postgresql/pgbackrest/doc/example/pgsql-pgbackrest-query.sql
name | last_successful_backup | last_archived_wal --------+------------------------+-------------------------- "demo" | 2024-08-19 03:01:14+00 | 000000010000000000000006 (1 row)
sudo apt-get install jq
sudo -u postgres pgbackrest --output=json --stanza=demo info | \ jq '.[0] | .backup[-1] | .timestamp.stop'
1724036474
sudo -u postgres pgbackrest --output=json --stanza=demo info | \ jq '.[0] | .archive[-1] | .max'
"000000010000000000000006"
sudo -u postgres pgbackrest --stanza=demo --type=full backup
sudo -u postgres find /var/lib/pgbackrest/backup/demo/latest/ -type f | wc -l
5
sudo -u postgres pgbackrest --stanza=demo --annotation=source="demo backup" \ --annotation=key=value --type=full backup
sudo -u postgres pgbackrest --stanza=demo --set=20240819-030130F info
stanza: demo status: ok cipher: aes-256-cbc db (current) wal archive min/max (15): 000000020000000000000008/00000002000000000000000A full backup: 20240819-030130F timestamp start/stop: 2024-08-19 03:01:30+00 / 2024-08-19 03:01:33+00 wal start/stop: 000000020000000000000009 / 00000002000000000000000A lsn start/stop: 0/9000028 / 0/A000088 database size: 21.8MB, database backup size: 21.8MB repo1: backup size: 2.9MB database list: postgres (5)
annotation(s)
key: value source: demo backup
sudo -u postgres pgbackrest --stanza=demo --set=20240819-030130F \ --annotation=key= --annotation=new_key=new_value annotate
sudo -u postgres pgbackrest --stanza=demo --set=20240819-030130F info
stanza: demo status: ok cipher: aes-256-cbc db (current) wal archive min/max (15): 000000020000000000000008/00000002000000000000000A full backup: 20240819-030130F timestamp start/stop: 2024-08-19 03:01:30+00 / 2024-08-19 03:01:33+00 wal start/stop: 000000020000000000000009 / 00000002000000000000000A lsn start/stop: 0/9000028 / 0/A000088 database size: 21.8MB, database backup size: 21.8MB repo1: backup size: 2.9MB database list: postgres (5)
annotation(s)
new_key: new_value source: demo backup
sudo -u postgres pgbackrest --stanza=demo --type=full \ --log-level-console=detail backup
[filtered 973 lines of output] P00 INFO: repo1: remove expired backup 20240819-030126F P00 DETAIL: repo1: 15-1 archive retention on backup 20240819-030130F, start = 000000020000000000000009
P00 INFO: repo1: 15-1 remove archive, start = 000000020000000000000008, stop = 000000020000000000000008
P00 INFO: expire command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo --type=full \ --log-level-console=info backup
[filtered 11 lines of output] P00 INFO: repo1: expire full backup 20240819-030130F P00 INFO: repo1: remove expired backup 20240819-030130F
P00 INFO: repo1: 15-1 remove archive, start = 000000020000000000000009, stop = 00000002000000000000000A
P00 INFO: expire command end: completed successfully
rollingset of differentials for the last day or more. This allows quick restores to recent points-in-time but reduces overall space consumption.
sudo -u postgres pgbackrest --stanza=demo --type=diff backup
sudo -u postgres pgbackrest --stanza=demo --type=incr backup
sudo -u postgres pgbackrest --stanza=demo --type=diff \ --log-level-console=info backup
[filtered 10 lines of output] P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.53.1: --exec-id=889-0f63b9f0 --log-level-console=info --no-log-timestamp --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-diff=1 --repo1-retention-full=2 --stanza=demo
P00 INFO: repo1: expire diff backup set 20240819-030138F_20240819-030141D, 20240819-030138F_20240819-030143I
P00 INFO: repo1: remove expired backup 20240819-030138F_20240819-030143I P00 INFO: repo1: remove expired backup 20240819-030138F_20240819-030141D 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 = 000000020000000000000018, lsn = 0/18000050 P00 INFO: check archive for segment(s) 000000020000000000000017:000000020000000000000018
P00 INFO: new backup label = 20240819-030138F_20240819-030148D
P00 INFO: diff backup size = 8.3KB, file total = 961 P00 INFO: backup command end: completed successfully [filtered 2 lines of output]
sudo -u postgres pgbackrest --stanza=demo --log-level-console=detail \ --repo1-retention-archive-type=diff --repo1-retention-archive=1 expire
P00 INFO: expire command begin 2.53.1: --exec-id=966-6e5d87fa --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: 15-1 archive retention on backup 20240819-030135F, start = 00000002000000000000000B, stop = 00000002000000000000000C P00 DETAIL: repo1: 15-1 archive retention on backup 20240819-030138F, start = 00000002000000000000000D, stop = 00000002000000000000000E
P00 DETAIL: repo1: 15-1 archive retention on backup 20240819-030138F_20240819-030145D, start = 000000020000000000000013, stop = 000000020000000000000014
P00 DETAIL: repo1: 15-1 archive retention on backup 20240819-030138F_20240819-030148D, start = 000000020000000000000017
P00 INFO: repo1: 15-1 remove archive, start = 00000002000000000000000F, stop = 000000020000000000000012 P00 INFO: repo1: 15-1 remove archive, start = 000000020000000000000015, stop = 000000020000000000000016
P00 INFO: expire command end: completed successfully
sudo pg_ctlcluster 15 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta \ --log-level-console=detail restore
[filtered 2 lines of output] P00 DETAIL: check '/var/lib/postgresql/15/demo' exists P00 DETAIL: remove 'global/pg_control' so cluster will not start if restore does not complete
P00 INFO: remove invalid files/links/paths from '/var/lib/postgresql/15/demo'
P00 DETAIL: remove invalid file '/var/lib/postgresql/15/demo/backup_label.old' P00 DETAIL: remove invalid file '/var/lib/postgresql/15/demo/base/1/pg_internal.init' [filtered 129 lines of output] P01 DETAIL: restore file /var/lib/postgresql/15/demo/base/1/113 - exists and matches backup (bundle 20240819-030138F/1/58072, 8KB, 5.80%) checksum 9c6671806c84144652aa7a1e989bc2cfe3d9bd40 P01 DETAIL: restore file /var/lib/postgresql/15/demo/base/1/112 - exists and matches backup (bundle 20240819-030138F/1/58160, 8KB, 5.83%) checksum 9890dd22d170e0de4f4d9404aba2557a33b9909b
P01 DETAIL: restore file /var/lib/postgresql/15/demo/PG_VERSION - exists and matches backup (bundle 20240819-030138F/1/58248, 3B, 5.83%) checksum 587b596f04f7db9c2cad3d6b87dd2b3a05de4f35
P01 DETAIL: restore file /var/lib/postgresql/15/demo/global/2695 - exists and matches backup (bundle 20240819-030138F/1/58272, 16KB, 5.91%) checksum 843d45d7c839660378249350bae98ab512a70e30 P01 DETAIL: restore file /var/lib/postgresql/15/demo/global/2694 - exists and matches backup (bundle 20240819-030138F/1/58480, 16KB, 5.98%) checksum 88e1fb6d0708cf9fa40378bf8a02d167d4f3f7e9 [filtered 870 lines of output]
sudo pg_ctlcluster 15 demo start
sudo -u postgres psql -c "create database test1;"
CREATE DATABASE
sudo -u postgres psql -c "create database test2;"
CREATE DATABASE
sudo -u postgres psql -c "create table test1_table (id int); \ insert into test1_table (id) values (1);" test1
CREATE TABLE INSERT 0 1
sudo -u postgres psql -c "create table test2_table (id int); \ insert into test2_table (id) values (2);" test2
CREATE TABLE INSERT 0 1
sudo -u postgres pgbackrest --stanza=demo --type=incr backup
sudo -u postgres du -sh /var/lib/postgresql/15/demo/base/32768
7.3M /var/lib/postgresql/15/demo/base/32768
sudo -u postgres pgbackrest --stanza=demo \ --set=20240819-030138F_20240819-030156I info
[filtered 12 lines of output] repo1: backup size: 2.0MB backup reference list: 20240819-030138F, 20240819-030138F_20240819-030148D
database list: postgres (5), test1 (32768), test2 (32769)
sudo pg_ctlcluster 15 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta \ --db-include=test2 --type=immediate --target-action=promote restore
sudo pg_ctlcluster 15 demo start
sudo -u postgres psql -c "select * from test2_table;" test2
id ---- 2 (1 row)
sudo -u postgres psql -c "select * from test1_table;" test1
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: relation mapping file "base/32768/pg_filenode.map" contains invalid data
sudo -u postgres du -sh /var/lib/postgresql/15/demo/base/32768
8.0K /var/lib/postgresql/15/demo/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 4 | template0 5 | 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;"
[filtered 4 lines of output] message ----------------
Important Data
(1 row)
sudo -u postgres psql -Atc "select current_timestamp"
2024-08-19 03:02:07.322658+00
sudo -u postgres psql -c "begin; \ drop table important_table; \ commit; \ select * from important_table;"
BEGIN DROP TABLE
COMMITERROR: relation "important_table" does not exist
LINE 1: ...le important_table; commit; select * from important_... ^
sudo -u postgres pgbackrest --stanza=demo --type=incr backup
sudo -u postgres pgbackrest info
[filtered 38 lines of output] backup reference list: 20240819-030138F, 20240819-030138F_20240819-030148D
incr backup: 20240819-030138F_20240819-030209I
timestamp start/stop: 2024-08-19 03:02:09+00 / 2024-08-19 03:02:10+00 wal start/stop: 00000004000000000000001B / 00000004000000000000001B [filtered 2 lines of output]
sudo pg_ctlcluster 15 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta \ --set=20240819-030138F_20240819-030209I --target-timeline=current \ --type=time "--target=2024-08-19 03:02:07.322658+00" --target-action=promote restore
sudo pg_ctlcluster 15 demo start
[filtered 13 lines of output] LOG: database system is ready to accept read-only connections LOG: redo done at 0/1B000100 system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.02 s
FATAL: recovery ended before configured recovery target was reached
LOG: startup process (PID 1334) exited with exit code 1 LOG: terminating any other active server processes [filtered 3 lines of output]
sudo -u postgres pgbackrest --stanza=demo --delta \ --type=time "--target=2024-08-19 03:02:07.322658+00" \ --target-action=promote restore
sudo -u postgres cat /var/lib/postgresql/15/demo/postgresql.auto.conf
[filtered 9 lines of output] # Recovery settings generated by pgBackRest restore on 2024-08-19 03:02:12 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'
recovery_target_time = '2024-08-19 03:02:07.322658+00'
recovery_target_action = 'promote'
sudo pg_ctlcluster 15 demo start
sudo -u postgres psql -c "select * from important_table"
message ----------------
Important Data
(1 row)
sudo -u postgres cat /var/log/postgresql/postgresql-15-demo.log
[filtered 4 lines of output] LOG: database system was interrupted; last known up at 2024-08-19 03:01:57 UTC LOG: restored log file "00000004.history" from archive
LOG: starting point-in-time recovery to 2024-08-19 03:02:07.322658+00
LOG: starting backup recovery with redo LSN 0/1A000028, checkpoint LSN 0/1A000060, on timeline ID 3 LOG: restored log file "00000004.history" from archive [filtered 5 lines of output] LOG: database system is ready to accept read-only connections LOG: restored log file "00000004000000000000001B" from archive
LOG: recovery stopping before commit of transaction 734, time 2024-08-19 03:02:08.616847+00
LOG: redo done at 0/1A0253C8 system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.06 s
LOG: last completed transaction was at log time 2024-08-19 03:02:06.047989+00
LOG: restored log file "00000004000000000000001A" from archive LOG: selected new timeline ID: 5 [filtered 5 lines of output]
sudo pg_ctlcluster 15 demo stop
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stop
P00 INFO: stop command begin 2.53.1: --exec-id=1456-4176d223 --log-level-console=info --no-log-timestamp --stanza=demo
P00 INFO: stop command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo --repo=1 \ --log-level-console=info stanza-delete
P00 INFO: stanza-delete command begin 2.53.1: --exec-id=1463-b7527523 --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/postgresql/15/demo --repo=1 --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --stanza=demo
P00 INFO: stanza-delete command end: completed successfully
hierarchical namespaceas this will cause errors during expire.
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stanza-create
P00 INFO: stanza-create command begin 2.53.1: --exec-id=1529-9ec8074b --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/postgresql/15/demo --repo2-azure-account=--repo2-azure-container=demo-container --repo2-azure-key= --repo1-cipher-pass= --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo2-type=azure --stanza=demo P00 INFO: stanza-create for stanza 'demo' on repo1 P00 INFO: stanza-create for stanza 'demo' on repo2
P00 INFO: stanza-create command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo --repo=2 \ --log-level-console=info backup
P00 INFO: backup command begin 2.53.1: --exec-id=1537-688d6cdc --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/postgresql/15/demo --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 = 00000005000000000000001C, lsn = 0/1C000028 [filtered 3 lines of output] P00 INFO: check archive for segment(s) 00000005000000000000001C:00000005000000000000001C P00 INFO: new backup label = 20240819-030223F
P00 INFO: full backup size = 29.0MB, file total = 1263
P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.53.1: --exec-id=1537-688d6cdc --log-level-console=info --no-log-timestamp --repo=2 --repo2-azure-account=--repo2-azure-container=demo-container --repo2-azure-key= --repo1-cipher-pass= --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo1-retention-diff=2 --repo1-retention-full=2 --repo2-retention-full=4 --repo2-type=azure --stanza=demo
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:ListBucket" ], "Resource": [ "arn:aws:s3:::demo-bucket" ], "Condition": { "StringEquals": { "s3:prefix": [ "", "demo-repo" ], "s3:delimiter": [ "/" ] } } }, { "Effect": "Allow", "Action": [ "s3:ListBucket" ], "Resource": [ "arn:aws:s3:::demo-bucket" ], "Condition": { "StringLike": { "s3:prefix": [ "demo-repo/*" ] } } }, { "Effect": "Allow", "Action": [ "s3:PutObject", "s3:PutObjectTagging", "s3:GetObject", "s3:DeleteObject" ], "Resource": [ "arn:aws:s3:::demo-bucket/demo-repo/*" ] } ] }
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stanza-create
[filtered 4 lines of output] P00 INFO: stanza 'demo' already exists on repo2 and is valid P00 INFO: stanza-create for stanza 'demo' on repo3
P00 INFO: stanza-create command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo --repo=3 \ --log-level-console=info backup
P00 INFO: backup command begin 2.53.1: --exec-id=1595-28186a12 --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/postgresql/15/demo --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 = 00000005000000000000001D, lsn = 0/1D000028 [filtered 3 lines of output] P00 INFO: check archive for segment(s) 00000005000000000000001D:00000005000000000000001E P00 INFO: new backup label = 20240819-030233F
P00 INFO: full backup size = 29.0MB, file total = 1263
P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.53.1: --exec-id=1595-28186a12 --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/postgresql/.ssh
sudo -u postgres ssh-keygen -f /var/lib/postgresql/.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/postgresql/.ssh/id_rsa_sftp.pub) | \ sudo -u pgbackrest tee -a /home/pgbackrest/.ssh/authorized_keys
strict
ssh-keyscan -H sftp-server >> /var/lib/postgresql/.ssh/known_hosts 2>/dev/null
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stanza-create
[filtered 6 lines of output] P00 INFO: stanza 'demo' already exists on repo3 and is valid P00 INFO: stanza-create for stanza 'demo' on repo4
P00 INFO: stanza-create command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo --repo=4 \ --log-level-console=info backup
P00 INFO: backup command begin 2.53.1: --exec-id=1670-6aa69a7d --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/postgresql/15/demo --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/postgresql/.ssh/id_rsa_sftp --repo4-sftp-public-key-file=/var/lib/postgresql/.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 = 00000005000000000000001F, lsn = 0/1F000028 [filtered 3 lines of output] P00 INFO: check archive for segment(s) 00000005000000000000001F:000000050000000000000020 P00 INFO: new backup label = 20240819-030243F
P00 INFO: full backup size = 29.0MB, file total = 1263
P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.53.1: --exec-id=1670-6aa69a7d --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/postgresql/.ssh/id_rsa_sftp --repo4-sftp-public-key-file=/var/lib/postgresql/.ssh/id_rsa_sftp.pub --repo2-type=azure --repo3-type=s3 --repo4-type=sftp --stanza=demo P00 INFO: expire command end: completed successfully
sudo adduser --disabled-password --gecos "" pgbackrest
sudo apt-get install postgresql-client libxml2 libssh2-1
sudo scp build:/build/pgbackrest/src/pgbackrest /usr/bin
sudo chmod 755 /usr/bin/pgbackrest
sudo mkdir -p -m 770 /var/log/pgbackrest
sudo chown pgbackrest:pgbackrest /var/log/pgbackrest
sudo mkdir -p /etc/pgbackrest
sudo mkdir -p /etc/pgbackrest/conf.d
sudo touch /etc/pgbackrest/pgbackrest.conf
sudo chmod 640 /etc/pgbackrest/pgbackrest.conf
sudo chown pgbackrest:pgbackrest /etc/pgbackrest/pgbackrest.conf
sudo mkdir -p /var/lib/pgbackrest
sudo chmod 750 /var/lib/pgbackrest
sudo chown pgbackrest:pgbackrest /var/lib/pgbackrest
sudo -u pgbackrest mkdir -m 750 /home/pgbackrest/.ssh
sudo -u pgbackrest ssh-keygen -f /home/pgbackrest/.ssh/id_rsa \ -t rsa -b 4096 -N ""
sudo -u postgres mkdir -m 750 -p /var/lib/postgresql/.ssh
sudo -u postgres ssh-keygen -f /var/lib/postgresql/.ssh/id_rsa \ -t rsa -b 4096 -N ""
(echo -n 'no-agent-forwarding,no-X11-forwarding,no-port-forwarding,' && \ echo -n 'command="/usr/bin/pgbackrest ${SSH_ORIGINAL_COMMAND#* }" ' && \ sudo ssh root@pg-primary cat /var/lib/postgresql/.ssh/id_rsa.pub) | \ sudo -u pgbackrest tee -a /home/pgbackrest/.ssh/authorized_keys
(echo -n 'no-agent-forwarding,no-X11-forwarding,no-port-forwarding,' && \ echo -n 'command="/usr/bin/pgbackrest ${SSH_ORIGINAL_COMMAND#* }" ' && \ sudo ssh root@repository cat /home/pgbackrest/.ssh/id_rsa.pub) | \ sudo -u postgres tee -a /var/lib/postgresql/.ssh/authorized_keys
sudo -u pgbackrest ssh postgres@pg-primary
sudo -u postgres ssh pgbackrest@repository
sudo -u pgbackrest pgbackrest --stanza=demo stanza-create
sudo -u postgres pgbackrest --stanza=demo check
sudo -u pgbackrest pgbackrest --stanza=demo check
sudo -u pgbackrest pgbackrest --stanza=demo backup
P00 WARN: no prior backup exists, incr backup has been changed to full
sudo pg_ctlcluster 15 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta restore
sudo pg_ctlcluster 15 demo start
sudo -u pgbackrest pgbackrest --stanza=demo --type=full backup
sudo -u pgbackrest pgbackrest --stanza=demo --type=full backup
sudo -u pgbackrest pgbackrest info
stanza: demo status: ok cipher: none db (current) wal archive min/max (15): 000000060000000000000026/000000060000000000000028 full backup: 20240819-030314F
timestamp start/stop: 2024-08-19 03:03:14+00 / 2024-08-19 03:03:19+00
wal start/stop: 000000060000000000000026 / 000000060000000000000026 database size: 29.0MB, database backup size: 29.0MB repo1: backup set size: 3.9MB, backup size: 3.9MB full backup: 20240819-030320F
timestamp start/stop: 2024-08-19 03:03:20+00 / 2024-08-19 03:03:25+00
wal start/stop: 000000060000000000000027 / 000000060000000000000028 database size: 29.0MB, database backup size: 29.0MB repo1: backup set size: 3.9MB, backup size: 3.9MB
sudo -u postgres pgbackrest stop
sudo -u pgbackrest pgbackrest --stanza=demo backup
P00 WARN: unable to check pg1: [StopError] raised from remote-0 ssh protocol on 'pg-primary': stop file exists for all stanzas
P00 ERROR: [056]: unable to find primary cluster - cannot proceed 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 ssh 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 apt-get install postgresql-client libxml2 libssh2-1
sudo scp build:/build/pgbackrest/src/pgbackrest /usr/bin
sudo chmod 755 /usr/bin/pgbackrest
sudo mkdir -p -m 770 /var/log/pgbackrest
sudo chown postgres:postgres /var/log/pgbackrest
sudo mkdir -p /etc/pgbackrest
sudo mkdir -p /etc/pgbackrest/conf.d
sudo touch /etc/pgbackrest/pgbackrest.conf
sudo chmod 640 /etc/pgbackrest/pgbackrest.conf
sudo chown postgres:postgres /etc/pgbackrest/pgbackrest.conf
sudo -u postgres mkdir -m 750 -p /var/lib/postgresql/.ssh
sudo -u postgres ssh-keygen -f /var/lib/postgresql/.ssh/id_rsa \ -t rsa -b 4096 -N ""
(echo -n 'no-agent-forwarding,no-X11-forwarding,no-port-forwarding,' && \ echo -n 'command="/usr/bin/pgbackrest ${SSH_ORIGINAL_COMMAND#* }" ' && \ sudo ssh root@pg-standby cat /var/lib/postgresql/.ssh/id_rsa.pub) | \ sudo -u pgbackrest tee -a /home/pgbackrest/.ssh/authorized_keys
(echo -n 'no-agent-forwarding,no-X11-forwarding,no-port-forwarding,' && \ echo -n 'command="/usr/bin/pgbackrest ${SSH_ORIGINAL_COMMAND#* }" ' && \ sudo ssh root@repository cat /home/pgbackrest/.ssh/id_rsa.pub) | \ sudo -u postgres tee -a /var/lib/postgresql/.ssh/authorized_keys
sudo -u pgbackrest ssh postgres@pg-standby
sudo -u postgres ssh pgbackrest@repository
sudo pg_createcluster 15 demo
sudo -u postgres pgbackrest --stanza=demo --delta --type=standby restore
sudo -u postgres cat /var/lib/postgresql/15/demo/postgresql.auto.conf
# Do not edit this file manually! # It will be overwritten by the ALTER SYSTEM command. # Recovery settings generated by pgBackRest restore on 2024-08-19 03:01:16 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-08-19 03:01:50 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-08-19 03:02:12 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Removed by pgBackRest restore on 2024-08-19 03:03:08 # recovery_target_time = '2024-08-19 03:02:07.322658+00' # Removed by pgBackRest restore on 2024-08-19 03:03:08 # recovery_target_action = 'promote' # Recovery settings generated by pgBackRest restore on 2024-08-19 03:03:08 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-08-19 03:03:38 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'
sudo pg_ctlcluster 15 demo start
sudo -u postgres cat /var/log/postgresql/postgresql-15-demo.log
[filtered 3 lines of output] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" LOG: database system was interrupted; last known up at 2024-08-19 03:03:21 UTC
LOG: entering standby mode
LOG: starting backup recovery with redo LSN 0/27000028, checkpoint LSN 0/27000060, on timeline ID 6 LOG: restored log file "00000006.history" from archive [filtered 6 lines of output]
sudo -u postgres psql -c " \ begin; \ create table replicated_table (message text); \ insert into replicated_table values ('Important Data'); \ commit; \ select * from replicated_table";
[filtered 4 lines of output] 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/29019A40 | 2024-08-19 03:03:45.746669+00 (1 row)
sudo -u postgres psql -c " \ select *, current_timestamp from replicated_table"
message | current_timestamp ----------------+-------------------------------
Important Data | 2024-08-19 03:03:47.039362+00
(1 row)
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info check
P00 INFO: check command begin 2.53.1: --exec-id=463-63329c19 --log-level-console=info --log-level-file=detail --no-log-timestamp --pg1-path=/var/lib/postgresql/15/demo --repo1-host=repository --stanza=demo P00 INFO: check repo1 (standby)
P00 INFO: switch wal not performed because this is a standby
P00 INFO: check command end: completed successfully
sudo -u postgres psql -c " \ create user replicator password 'jw8s0F4' replication";
CREATE ROLE
sudo -u postgres sh -c 'echo \ "host replication replicator 172.17.0.8/32 md5" \ >> /etc/postgresql/15/demo/pg_hba.conf'
sudo pg_ctlcluster 15 demo reload
sudo -u postgres sh -c 'echo \ "172.17.0.6:*:replication:replicator:jw8s0F4" \ >> /var/lib/postgresql/.pgpass'
sudo -u postgres chmod 600 /var/lib/postgresql/.pgpass
sudo pg_ctlcluster 15 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta --type=standby restore
sudo -u postgres cat /var/lib/postgresql/15/demo/postgresql.auto.conf
# Do not edit this file manually! # It will be overwritten by the ALTER SYSTEM command. # Recovery settings generated by pgBackRest restore on 2024-08-19 03:01:16 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-08-19 03:01:50 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-08-19 03:02:12 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Removed by pgBackRest restore on 2024-08-19 03:03:08 # recovery_target_time = '2024-08-19 03:02:07.322658+00' # Removed by pgBackRest restore on 2024-08-19 03:03:08 # recovery_target_action = 'promote' # Recovery settings generated by pgBackRest restore on 2024-08-19 03:03:08 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2024-08-19 03:03:50 primary_conninfo = 'host=172.17.0.6 port=5432 user=replicator' restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'
sudo pg_ctlcluster 15 demo start
sudo -u postgres cat /var/log/postgresql/postgresql-15-demo.log
[filtered 13 lines of output] LOG: consistent recovery state reached at 0/28000088 LOG: database system is ready to accept read-only connections
LOG: started streaming WAL from primary at 0/2A000000 on timeline 6
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";
[filtered 4 lines of output] message | current_timestamp ----------------+-------------------------------
Important Data | 2024-08-19 03:03:56.407075+00
(1 row)
sudo -u postgres psql -c " \ select *, current_timestamp from stream_table"
message | current_timestamp ----------------+-------------------------------
Important Data | 2024-08-19 03:03:56.751981+00
(1 row)
sudo apt-get install postgresql-client libxml2 libssh2-1
sudo scp build:/build/pgbackrest/src/pgbackrest /usr/bin
sudo chmod 755 /usr/bin/pgbackrest
sudo mkdir -p -m 770 /var/log/pgbackrest
sudo chown postgres:postgres /var/log/pgbackrest
sudo mkdir -p /etc/pgbackrest
sudo mkdir -p /etc/pgbackrest/conf.d
sudo touch /etc/pgbackrest/pgbackrest.conf
sudo chmod 640 /etc/pgbackrest/pgbackrest.conf
sudo chown postgres:postgres /etc/pgbackrest/pgbackrest.conf
sudo -u postgres mkdir -m 750 -p /var/lib/postgresql/.ssh
sudo -u postgres ssh-keygen -f /var/lib/postgresql/.ssh/id_rsa \ -t rsa -b 4096 -N ""
(echo -n 'no-agent-forwarding,no-X11-forwarding,no-port-forwarding,' && \ echo -n 'command="/usr/bin/pgbackrest ${SSH_ORIGINAL_COMMAND#* }" ' && \ sudo ssh root@pg-alt cat /var/lib/postgresql/.ssh/id_rsa.pub) | \ sudo -u pgbackrest tee -a /home/pgbackrest/.ssh/authorized_keys
(echo -n 'no-agent-forwarding,no-X11-forwarding,no-port-forwarding,' && \ echo -n 'command="/usr/bin/pgbackrest ${SSH_ORIGINAL_COMMAND#* }" ' && \ sudo ssh root@repository cat /home/pgbackrest/.ssh/id_rsa.pub) | \ sudo -u postgres tee -a /var/lib/postgresql/.ssh/authorized_keys
sudo -u pgbackrest ssh postgres@pg-alt
sudo -u postgres ssh pgbackrest@repository
sudo -u postgres /usr/lib/postgresql/15/bin/initdb \ -D /var/lib/postgresql/15/demo -k -A peer
sudo pg_createcluster 15 demo
Configuring already existing cluster (configuration: /etc/postgresql/15/demo, data: /var/lib/postgresql/15/demo, owner: 102:103) Ver Cluster Port Status Owner Data directory Log file 15 demo 5432 down postgres /var/lib/postgresql/15/demo /var/log/postgresql/postgresql-15-demo.log
sudo pg_ctlcluster 15 demo restart
sudo -u postgres pgbackrest --stanza=demo-alt --log-level-console=info stanza-create
P00 INFO: stanza-create command begin 2.53.1: --exec-id=359-26a5cce4 --log-level-console=info --log-level-file=detail --no-log-timestamp --pg1-path=/var/lib/postgresql/15/demo --repo1-host=repository --stanza=demo-alt P00 INFO: stanza-create for stanza 'demo-alt' on repo1
P00 INFO: stanza-create command end: completed successfully
sudo -u postgres pgbackrest --log-level-console=info check
P00 INFO: check command begin 2.53.1: --exec-id=369-e0f6575c --log-level-console=info --log-level-file=detail --no-log-timestamp --repo1-host=repository
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/15-1/0000000100000000/000000010000000000000001-8d9f4e601b63f4157a6d34f8ca1353ac14a2c409.gz' on repo1
P00 INFO: check command end: completed successfully
sudo -u pgbackrest pgbackrest --log-level-console=info check
P00 INFO: check command begin 2.53.1: --exec-id=1199-6536f86c --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 00000006000000000000002A successfully archived to '/var/lib/pgbackrest/archive/demo/15-1/0000000600000000/00000006000000000000002A-8206f60cf2e01d3b9f86adc4290367a7e7cf6587.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/15-1/0000000100000000/000000010000000000000002-a0d0dea9fca4f2cbb74e0b5b6eac75b05cc3d8f7.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 pg_ctlcluster 15 demo restart
looking aheadto see which WAL segments are ready to be archived beyond the request that PostgreSQL is currently making via the archive_command. WAL segments are transferred to the archive directly from the pg_xlog/pg_wal directory and success is only returned by the archive_command when the WAL segment has been safely stored in the archive.
sudo -u postgres psql -c " \ select pg_create_restore_point('test async push'); select pg_switch_wal(); \ select pg_create_restore_point('test async push'); select pg_switch_wal(); \ select pg_create_restore_point('test async push'); select pg_switch_wal(); \ select pg_create_restore_point('test async push'); select pg_switch_wal(); \ select pg_create_restore_point('test async push'); select pg_switch_wal();"
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info check
P00 INFO: check command begin 2.53.1: --exec-id=2245-86d67b91 --log-level-console=info --log-level-file=detail --no-log-timestamp --pg1-path=/var/lib/postgresql/15/demo --repo1-host=repository --stanza=demo P00 INFO: check repo1 configuration (primary) P00 INFO: check repo1 archive for WAL (primary)
P00 INFO: WAL segment 000000060000000000000030 successfully archived to '/var/lib/pgbackrest/archive/demo/15-1/0000000600000000/000000060000000000000030-be9b47a13ccf17a94d566b70146f51e4306fc0a8.gz' on repo1
P00 INFO: check command end: completed successfully
sudo -u postgres cat /var/log/pgbackrest/demo-archive-push-async.log
-------------------PROCESS START------------------- P00 INFO: archive-push:async command begin 2.53.1: [/var/lib/postgresql/15/demo/pg_wal] --archive-async --exec-id=2232-f52885ad --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/15/demo --process-max=2 --repo1-host=repository --spool-path=/var/spool/pgbackrest --stanza=demo
P00 INFO: push 1 WAL file(s) to archive: 00000006000000000000002B P01 DETAIL: pushed WAL file '00000006000000000000002B' to the archive
P00 INFO: archive-push:async command end: completed successfully -------------------PROCESS START------------------- P00 INFO: archive-push:async command begin 2.53.1: [/var/lib/postgresql/15/demo/pg_wal] --archive-async --exec-id=2249-de25eb70 --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/15/demo --process-max=2 --repo1-host=repository --spool-path=/var/spool/pgbackrest --stanza=demo
P00 INFO: push 4 WAL file(s) to archive: 00000006000000000000002C...00000006000000000000002F P02 DETAIL: pushed WAL file '00000006000000000000002D' to the archive P01 DETAIL: pushed WAL file '00000006000000000000002C' to the archive P02 DETAIL: pushed WAL file '00000006000000000000002E' to the archive P01 DETAIL: pushed WAL file '00000006000000000000002F' to the archive
P00 INFO: archive-push:async command end: completed successfully -------------------PROCESS START------------------- P00 INFO: archive-push:async command begin 2.53.1: [/var/lib/postgresql/15/demo/pg_wal] --archive-async --exec-id=2264-961ead89 --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/15/demo --process-max=2 --repo1-host=repository --spool-path=/var/spool/pgbackrest --stanza=demo
P00 INFO: push 1 WAL file(s) to archive: 000000060000000000000030 P01 DETAIL: pushed WAL file '000000060000000000000030' to the archive
P00 INFO: archive-push:async command end: completed successfully
sudo -u postgres cat /var/log/pgbackrest/demo-archive-get-async.log
-------------------PROCESS START------------------- P00 INFO: archive-get:async command begin 2.53.1: [000000060000000000000027, 000000060000000000000028, 000000060000000000000029, 00000006000000000000002A, 00000006000000000000002B, 00000006000000000000002C, 00000006000000000000002D, 00000006000000000000002E] --archive-async --exec-id=663-9493e390 --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/15/demo --process-max=2 --repo1-host=repository --spool-path=/var/spool/pgbackrest --stanza=demo P00 INFO: get 8 WAL file(s) from archive: 000000060000000000000027...00000006000000000000002E
P02 DETAIL: found 000000060000000000000028 in the repo1: 15-1 archive P01 DETAIL: found 000000060000000000000027 in the repo1: 15-1 archive P02 DETAIL: found 000000060000000000000029 in the repo1: 15-1 archive P01 DETAIL: found 00000006000000000000002A in the repo1: 15-1 archive
P00 DETAIL: unable to find 00000006000000000000002B in the archive P00 INFO: archive-get:async command end: completed successfully [filtered 14 lines of output] P00 INFO: archive-get:async command begin 2.53.1: [00000006000000000000002B, 00000006000000000000002C, 00000006000000000000002D, 00000006000000000000002E, 00000006000000000000002F, 000000060000000000000030, 000000060000000000000031, 000000060000000000000032] --archive-async --exec-id=706-1d6b201d --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/15/demo --process-max=2 --repo1-host=repository --spool-path=/var/spool/pgbackrest --stanza=demo P00 INFO: get 8 WAL file(s) from archive: 00000006000000000000002B...000000060000000000000032
P01 DETAIL: found 00000006000000000000002B in the repo1: 15-1 archive P02 DETAIL: found 00000006000000000000002C in the repo1: 15-1 archive P01 DETAIL: found 00000006000000000000002D in the repo1: 15-1 archive P02 DETAIL: found 00000006000000000000002E in the repo1: 15-1 archive P01 DETAIL: found 00000006000000000000002F in the repo1: 15-1 archive
P00 DETAIL: unable to find 000000060000000000000030 in the archive P00 INFO: archive-get:async command end: completed successfully [filtered 2 lines of output] P00 INFO: archive-get:async command begin 2.53.1: [000000060000000000000030, 000000060000000000000031, 000000060000000000000032, 000000060000000000000033, 000000060000000000000034, 000000060000000000000035, 000000060000000000000036, 000000060000000000000037] --archive-async --exec-id=723-8714fd68 --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/15/demo --process-max=2 --repo1-host=repository --spool-path=/var/spool/pgbackrest --stanza=demo P00 INFO: get 8 WAL file(s) from archive: 000000060000000000000030...000000060000000000000037
P01 DETAIL: found 000000060000000000000030 in the repo1: 15-1 archive
P00 DETAIL: unable to find 000000060000000000000031 in the archive P00 INFO: archive-get:async command end: completed successfully [filtered 17 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 = 000000060000000000000032, lsn = 0/32000028
P00 INFO: wait for replay on the standby to reach 0/32000028 P00 INFO: replay on the standby reached 0/32000028
P00 INFO: check archive for prior segment 000000060000000000000031
P01 DETAIL: backup file pg-primary:/var/lib/postgresql/15/demo/global/pg_control (8KB, 0.53%) checksum 7764e8c31b84a553d3cacfc7463f99a6ce9cf1a4
P01 DETAIL: match file from prior backup pg-primary:/var/lib/postgresql/15/demo/pg_logical/replorigin_checkpoint (8B, 0.53%) checksum 347fc8f2df71bd4436e38bd1516ccd7ea0d46532 P02 DETAIL: backup file pg-standby:/var/lib/postgresql/15/demo/base/5/1249 (456KB, 31.18%) checksum 38118237c5a3ab0615615263663b32faacf3cb1c [filtered 1276 lines of output]
sudo pg_ctlcluster 15 demo stop
sudo pg_ctlcluster 15 demo stop
sudo -u postgres /usr/lib/postgresql/16/bin/initdb \ -D /var/lib/postgresql/16/demo -k -A peer
sudo pg_createcluster 16 demo
sudo -u postgres sh -c 'cd /var/lib/postgresql && \ /usr/lib/postgresql/16/bin/pg_upgrade \ --old-bindir=/usr/lib/postgresql/15/bin \ --new-bindir=/usr/lib/postgresql/16/bin \ --old-datadir=/var/lib/postgresql/15/demo \ --new-datadir=/var/lib/postgresql/16/demo \ --old-options=" -c config_file=/etc/postgresql/15/demo/postgresql.conf" \ --new-options=" -c config_file=/etc/postgresql/16/demo/postgresql.conf"'
[filtered 42 lines of output] Checking for extension updates ok
Upgrade Complete
---------------- Optimizer statistics are not transferred by pg_upgrade. [filtered 3 lines of output]
sudo cp /etc/postgresql/15/demo/pg_hba.conf \ /etc/postgresql/16/demo/pg_hba.conf
sudo -u postgres pgbackrest --stanza=demo --no-online \ --log-level-console=info stanza-upgrade
P00 INFO: stanza-upgrade command begin 2.53.1: --exec-id=2661-67d61dce --log-level-console=info --log-level-file=detail --no-log-timestamp --no-online --pg1-path=/var/lib/postgresql/16/demo --repo1-host=repository --stanza=demo P00 INFO: stanza-upgrade for stanza 'demo' on repo1
P00 INFO: stanza-upgrade command end: completed successfully
sudo pg_ctlcluster 16 demo start
sudo -u postgres pg_lsclusters
sudo -u postgres pgbackrest --stanza=demo check
sudo pg_dropcluster 15 demo
sudo pg_dropcluster 15 demo
sudo pg_createcluster 16 demo
sudo -u pgbackrest pgbackrest --stanza=demo check
P00 WARN: unable to check pg2: [DbConnectError] raised from remote-0 ssh protocol on 'pg-standby': unable to connect to 'dbname='postgres' port=5432': connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory Is the server running locally and accepting connections on that socket?
sudo -u pgbackrest pgbackrest --stanza=demo --type=full backup
sudo -u postgres pgbackrest --stanza=demo --delta --type=standby restore
sudo pg_ctlcluster 16 demo start
sudo -u postgres pgbackrest --stanza=demo check