wget -q -O - \
https://github.com/pgbackrest/pgbackrest/archive/release/2.33.tar.gz | \
tar zx -C /buildsudo apt-get install make gcc libpq-dev libssl-dev libxml2-dev pkg-config \
liblz4-dev libzstd-dev libbz2-dev libz-devcd /build/pgbackrest-release-2.33/src && ./configure && make
sudo apt-get install postgresql-client libxml2
sudo scp build:/build/pgbackrest-release-2.33/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.33 - General help
Usage:
pgbackrest [options] [command]
Commands:
archive-get Get a WAL segment from the archive.
archive-push Push a WAL segment to the archive.
backup Backup a database cluster.
check Check the configuration.
expire Expire backups that exceed retention.
help Get help.
info Retrieve information about backups.
repo-get Get a file from a repository.
repo-ls List files in a repository.
restore Restore a database cluster.
stanza-create Create the required stanza data.
stanza-delete Delete a stanza.
stanza-upgrade Upgrade a stanza.
start Allow pgBackRest processes to run.
stop Stop pgBackRest processes from running.
version Get version.
Use 'pgbackrest help [command]' for more information.sudo -u postgres /usr/lib/postgresql/12/bin/initdb \
-D /var/lib/postgresql/12/demo -k -A peersudo pg_createcluster 12 demo
Configuring already existing cluster (configuration: /etc/postgresql/12/demo, data: /var/lib/postgresql/12/demo, owner: 106:110) Ver Cluster Port Status Owner Data directory Log file 12 demo 5432 down postgres /var/lib/postgresql/12/demo /var/log/postgresql/postgresql-12-demo.log
sudo -u postgres bash -c ' \
export PGBACKREST_LOG_PATH=/path/set/by/env && \
pgbackrest --log-level-console=error help backup log-path'pgBackRest 2.33 - 'backup' command - 'log-path' option help Path where log files are stored. The log path provides a location for pgBackRest to store log files. Note that if log-level-file=off then no log path is required.
current: /path/set/by/env
default: /var/log/pgbackrest
sudo mkdir -p /var/lib/pgbackrest
sudo chmod 750 /var/lib/pgbackrest
sudo chown postgres:postgres /var/lib/pgbackrest
sudo pg_ctlcluster 12 demo restart
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stanza-create
P00 INFO: stanza-create command begin 2.33: --exec-id=403-ad792aa3 --log-level-console=info --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --stanza=demo P00 INFO: stanza-create for stanza 'demo' on repo1
P00 INFO: stanza-create command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info check
P00 INFO: check command begin 2.33: --exec-id=412-e19ea93a --log-level-console=info --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --stanza=demo P00 INFO: check repo1 configuration (primary) P00 INFO: check repo1 archive for WAL (primary)
P00 INFO: WAL segment 000000010000000000000001 successfully archived to '/var/lib/pgbackrest/archive/demo/12-1/0000000100000000/000000010000000000000001-a1ae1a5ecb0f369f53855d01bef176c2b2e2d4f3.gz' on repo1
P00 INFO: check command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo \
--log-level-console=info backupP00 INFO: backup command begin 2.33: --exec-id=422-422e1f4d --log-level-console=info --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-full=2 --stanza=demo
P00 WARN: no prior backup exists, incr backup has been changed to full
P00 INFO: execute non-exclusive pg_start_backup(): backup begins after the next regular checkpoint completes
P00 INFO: backup start archive = 000000010000000000000002, lsn = 0/2000028
[filtered 973 lines of output]
P01 INFO: backup file /var/lib/postgresql/12/demo/base/1/13201 (0B, 100%)
P01 INFO: backup file /var/lib/postgresql/12/demo/base/1/13196 (0B, 100%)P00 INFO: full backup size = 23.4MB
P00 INFO: execute non-exclusive pg_stop_backup() and wait for all WAL segments to archive
P00 INFO: backup stop archive = 000000010000000000000002, lsn = 0/2000138
[filtered 4 lines of output]sudo -u postgres pgbackrest --stanza=demo --type=diff \
--log-level-console=info backup[filtered 4 lines of output] P01 INFO: backup file /var/lib/postgresql/12/demo/global/pg_control (8KB, 99%) checksum 92266f8bce37a7ba7265c1e24a5a40d3144787c4 P01 INFO: backup file /var/lib/postgresql/12/demo/pg_logical/replorigin_checkpoint (8B, 100%) checksum 347fc8f2df71bd4436e38bd1516ccd7ea0d46532
P00 INFO: diff backup size = 8KB
P00 INFO: execute non-exclusive pg_stop_backup() and wait for all WAL segments to archive
P00 INFO: backup stop archive = 000000010000000000000003, lsn = 0/3000100
[filtered 4 lines of output]#m h dom mon dow command 30 06 * * 0 pgbackrest --type=full --stanza=demo backup 30 06 * * 1-6 pgbackrest --type=diff --stanza=demo backup
sudo -u postgres pgbackrest info
stanza: demo
status: ok
cipher: aes-256-cbc
db (current)
wal archive min/max (12): 000000010000000000000001/000000010000000000000003
full backup: 20210402-181557F
timestamp start/stop: 2021-04-02 18:15:57 / 2021-04-02 18:16:11
wal start/stop: 000000010000000000000002 / 000000010000000000000002
database size: 23.4MB, database backup size: 23.4MB
repo1: backup set size: 2.8MB, backup size: 2.8MB
diff backup: 20210402-181557F_20210402-181612D
timestamp start/stop: 2021-04-02 18:16:12 / 2021-04-02 18:16:14
wal start/stop: 000000010000000000000003 / 000000010000000000000003
database size: 23.4MB, database backup size: 8.3KB
repo1: backup set size: 2.8MB, backup size: 496B
backup reference list: 20210402-181557Fsudo pg_ctlcluster 12 demo stop
sudo -u postgres rm /var/lib/postgresql/12/demo/global/pg_control
sudo pg_ctlcluster 12 demo start
Error: /usr/lib/postgresql/12/bin/pg_ctl /usr/lib/postgresql/12/bin/pg_ctl start -D /var/lib/postgresql/12/demo -l /var/log/postgresql/postgresql-12-demo.log -s -o -c config_file="/etc/postgresql/12/demo/postgresql.conf" exited with status 1:
postgres: could not find the database system
Expected to find it in the directory "/var/lib/postgresql/12/demo", but could not open file "/var/lib/postgresql/12/demo/global/pg_control": No such file or directory Examine the log output.
sudo -u postgres find /var/lib/postgresql/12/demo -mindepth 1 -delete
sudo -u postgres pgbackrest --stanza=demo restore
sudo pg_ctlcluster 12 demo start
sudo -u postgres pgbackrest --stanza=demo --type=incr \
--log-level-console=info backupP00 INFO: backup command begin 2.33: --exec-id=569-3d3d4830 --log-level-console=info --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-full=2 --stanza=demo --type=incr P00 INFO: last backup label = 20210402-181557F_20210402-181612D, version = 2.33
P00 INFO: execute non-exclusive pg_start_backup(): backup begins after the next regular checkpoint completes
P00 INFO: backup start archive = 000000020000000000000005, lsn = 0/5000028
P00 WARN: a timeline switch has occurred since the 20210402-181557F_20210402-181612D backup, enabling delta checksum
[filtered 10 lines of output]sudo -u postgres pgbackrest --stanza=demo --type=incr \
--log-level-console=info backupP00 INFO: backup command begin 2.33: --exec-id=601-9f2cf111 --log-level-console=info --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-full=2 --stanza=demo --start-fast --type=incr P00 INFO: last backup label = 20210402-181557F_20210402-181631I, version = 2.33
P00 INFO: execute non-exclusive pg_start_backup(): backup begins after the requested immediate checkpoint completes
P00 INFO: backup start archive = 000000020000000000000006, lsn = 0/6000028
P01 INFO: backup file /var/lib/postgresql/12/demo/global/pg_control (8KB, 99%) checksum e4fa9df07d9894347a1659af62230e229050f9e9
[filtered 8 lines of output]sudo -u postgres cat \
/var/lib/postgresql/pgbackrest/doc/example/pgsql-pgbackrest-info.sql-- An example of monitoring pgBackRest from within PostgreSQL
--
-- Use copy to export data from the pgBackRest info command into the jsonb
-- type so it can be queried directly by PostgreSQL.
-- Create monitor schema
create schema monitor;
-- Get pgBackRest info in JSON format
create function monitor.pgbackrest_info()
returns jsonb AS $$
declare
data jsonb;
begin
-- Create a temp table to hold the JSON data
create temp table temp_pgbackrest_data (data jsonb);
-- Copy data into the table directly from the pgBackRest info command
copy temp_pgbackrest_data (data)
from program
'pgbackrest --output=json info' (format text);
select temp_pgbackrest_data.data
into data
from temp_pgbackrest_data;
drop table temp_pgbackrest_data;
return data;
end $$ language plpgsql;sudo -u postgres psql -f \
/var/lib/postgresql/pgbackrest/doc/example/pgsql-pgbackrest-info.sqlsudo -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.sqlname | last_successful_backup | last_archived_wal --------+------------------------+-------------------------- "demo" | 2021-04-02 18:16:37+00 | 000000020000000000000006 (1 row)
sudo apt-get install jq
sudo -u postgres pgbackrest --output=json --stanza=demo info | \
jq '.[0] | .backup[-1] | .timestamp.stop'1617387397
sudo -u postgres pgbackrest --output=json --stanza=demo info | \
jq '.[0] | .archive[-1] | .max'"000000020000000000000006"
sudo -u postgres pgbackrest --stanza=demo --type=full \
--log-level-console=detail backup[filtered 984 lines of output] P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.33: --exec-id=755-438c0410 --log-level-console=detail --log-level-stderr=off --no-log-timestamp --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-full=2 --stanza=demo
P00 DETAIL: repo1: 12-1 archive retention on backup 20210402-181557F, start = 000000010000000000000002 P00 DETAIL: repo1: 12-1 remove archive, start = 000000010000000000000001, stop = 000000010000000000000001
P00 INFO: expire command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo --type=full \
--log-level-console=info backup[filtered 983 lines of output] P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.33: --exec-id=783-4f8dddd3 --log-level-console=info --log-level-stderr=off --no-log-timestamp --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-full=2 --stanza=demo
P00 INFO: repo1: expire full backup set 20210402-181557F, 20210402-181557F_20210402-181612D, 20210402-181557F_20210402-181631I, 20210402-181557F_20210402-181636I
P00 INFO: repo1: remove expired backup 20210402-181557F_20210402-181636I
P00 INFO: repo1: remove expired backup 20210402-181557F_20210402-181631I
[filtered 2 lines of output]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 11 lines of output] P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.33: --exec-id=854-2495c582 --log-level-console=info --log-level-stderr=off --no-log-timestamp --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-diff=1 --repo1-retention-full=2 --stanza=demo
P00 INFO: repo1: expire diff backup set 20210402-181659F_20210402-181717D, 20210402-181659F_20210402-181720I
P00 INFO: repo1: remove expired backup 20210402-181659F_20210402-181720I P00 INFO: repo1: remove expired backup 20210402-181659F_20210402-181717D
sudo -u postgres pgbackrest --stanza=demo --type=diff \
--log-level-console=info backup[filtered 9 lines of output] P00 INFO: backup stop archive = 000000020000000000000010, lsn = 0/10000100 P00 INFO: check archive for segment(s) 000000020000000000000010:000000020000000000000010
P00 INFO: new backup label = 20210402-181659F_20210402-181727D
P00 INFO: backup command end: completed successfully P00 INFO: expire command begin 2.33: --exec-id=917-edecad71 --log-level-console=info --log-level-stderr=off --no-log-timestamp --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-diff=2 --repo1-retention-full=2 --stanza=demo
sudo -u postgres pgbackrest --stanza=demo --log-level-console=detail \
--repo1-retention-archive-type=diff --repo1-retention-archive=1 expireP00 INFO: expire command begin 2.33: --exec-id=943-190e51c4 --log-level-console=detail --log-level-stderr=off --no-log-timestamp --repo1-cipher-pass=--repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-archive=1 --repo1-retention-archive-type=diff --repo1-retention-diff=2 --repo1-retention-full=2 --stanza=demo P00 DETAIL: repo1: 12-1 archive retention on backup 20210402-181645F, start = 000000020000000000000008, stop = 000000020000000000000008 P00 DETAIL: repo1: 12-1 archive retention on backup 20210402-181659F, start = 000000020000000000000009, stop = 000000020000000000000009
P00 DETAIL: repo1: 12-1 archive retention on backup 20210402-181659F_20210402-181723D, start = 00000002000000000000000C, stop = 00000002000000000000000C
P00 DETAIL: repo1: 12-1 archive retention on backup 20210402-181659F_20210402-181727D, start = 000000020000000000000010
P00 DETAIL: repo1: 12-1 remove archive, start = 00000002000000000000000A, stop = 00000002000000000000000B P00 DETAIL: repo1: 12-1 remove archive, start = 00000002000000000000000D, stop = 00000002000000000000000F
P00 INFO: expire command end: completed successfully
sudo pg_ctlcluster 12 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta \
--log-level-console=detail restore[filtered 2 lines of output] P00 DETAIL: check '/var/lib/postgresql/12/demo' exists P00 DETAIL: remove 'global/pg_control' so cluster will not start if restore does not complete
P00 INFO: remove invalid files/links/paths from '/var/lib/postgresql/12/demo'
P00 DETAIL: remove invalid file '/var/lib/postgresql/12/demo/backup_label.old'
P00 DETAIL: remove invalid file '/var/lib/postgresql/12/demo/base/1/pg_internal.init'
[filtered 816 lines of output]
P01 DETAIL: restore file /var/lib/postgresql/12/demo/base/13358/PG_VERSION - exists and matches backup (3B, 99%) checksum ad552e6dc057d1d825bf49df79d6b98eba846ebe
P01 DETAIL: restore file /var/lib/postgresql/12/demo/base/1/PG_VERSION - exists and matches backup (3B, 99%) checksum ad552e6dc057d1d825bf49df79d6b98eba846ebeP01 DETAIL: restore file /var/lib/postgresql/12/demo/PG_VERSION - exists and matches backup (3B, 100%) checksum ad552e6dc057d1d825bf49df79d6b98eba846ebe
P01 DETAIL: restore file /var/lib/postgresql/12/demo/global/6100 - exists and is zero size (0B, 100%)
P01 DETAIL: restore file /var/lib/postgresql/12/demo/global/6000 - exists and is zero size (0B, 100%)
[filtered 201 lines of output]sudo pg_ctlcluster 12 demo start
sudo -u postgres psql -c "create database test1;"
CREATE DATABASE
sudo -u postgres psql -c "create database test2;"
CREATE DATABASE
sudo -u postgres psql -c "create table test1_table (id int); \
insert into test1_table (id) values (1);" test1INSERT 0 1
sudo -u postgres psql -c "create table test2_table (id int); \
insert into test2_table (id) values (2);" test2INSERT 0 1
sudo -u postgres pgbackrest --stanza=demo --type=incr backup
sudo -u postgres du -sh /var/lib/postgresql/12/demo/base/24576
7.8M /var/lib/postgresql/12/demo/base/24576
sudo -u postgres pgbackrest --stanza=demo \
--set=20210402-181659F_20210402-181739I info [filtered 11 lines of output]
repo1: backup set size: 4.7MB, backup size: 1.9MB
backup reference list: 20210402-181659F, 20210402-181659F_20210402-181727Ddatabase list: postgres (13359), test1 (24576), test2 (24577)
sudo pg_ctlcluster 12 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta \
--db-include=test2 --type=immediate --target-action=promote restoresudo pg_ctlcluster 12 demo start
sudo -u postgres psql -c "select * from test2_table;" test2
id ---- 2 (1 row)
sudo -u postgres psql -c "select * from test1_table;" test1
psql: error: FATAL: relation mapping file "base/24576/pg_filenode.map" contains invalid data
sudo -u postgres du -sh /var/lib/postgresql/12/demo/base/24576
16K /var/lib/postgresql/12/demo/base/24576
sudo -u postgres psql -c "drop database test1;"
DROP DATABASE
sudo -u postgres psql -c "select oid, datname from pg_database order by oid;"
oid | datname
-------+-----------
1 | template1
13358 | template0
13359 | postgres24577 | test2
(4 rows)
sudo -u postgres pgbackrest --stanza=demo --type=diff backup
sudo -u postgres psql -c "begin; \
create table important_table (message text); \
insert into important_table values ('Important Data'); \
commit; \
select * from important_table;"message ----------------
Important Data
(1 row)
sudo -u postgres psql -Atc "select current_timestamp"
2021-04-02 18:18:08.135697+00
sudo -u postgres psql -c "begin; \
drop table important_table; \
commit; \
select * from important_table;"ERROR: relation "important_table" does not exist
LINE 1: ...le important_table; commit; select * from important_...
^sudo pg_ctlcluster 12 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta \
--type=time "--target=2021-04-02 18:18:08.135697+00" \
--target-action=promote restoresudo -u postgres cat /var/lib/postgresql/12/demo/postgresql.auto.conf
[filtered 14 lines of output] # Recovery settings generated by pgBackRest restore on 2021-04-02 18:18:10 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'
recovery_target_time = '2021-04-02 18:18:08.135697+00'
recovery_target_action = 'promote'
sudo pg_ctlcluster 12 demo start
sudo -u postgres psql -c "select * from important_table"
message ----------------
Important Data
(1 row)
sudo -u postgres cat /var/log/postgresql/postgresql-12-demo.log
[filtered 3 lines of output] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" LOG: database system was interrupted; last known up at 2021-04-02 18:18:00 UTC
LOG: starting point-in-time recovery to 2021-04-02 18:18:08.135697+00
LOG: restored log file "00000004.history" from archive
LOG: restored log file "000000040000000000000013" from archive
[filtered 2 lines of output]
LOG: database system is ready to accept read only connections
LOG: restored log file "000000040000000000000014" from archiveLOG: recovery stopping before commit of transaction 495, time 2021-04-02 18:18:09.393534+00
LOG: redo done at 0/14019E10
LOG: last completed transaction was at log time 2021-04-02 18:18:06.328008+00
LOG: selected new timeline ID: 5
LOG: archive recovery complete
[filtered 2 lines of output]sudo -u postgres psql -c "begin; \
drop table important_table; \
commit; \
select * from important_table;"ERROR: relation "important_table" does not exist
LINE 1: ...le important_table; commit; select * from important_...
^sudo -u postgres pgbackrest --stanza=demo --type=incr backup
sudo -u postgres pgbackrest info
stanza: demo
status: ok
cipher: aes-256-cbc
db (current)
wal archive min/max (12): 000000020000000000000008/000000050000000000000015
full backup: 20210402-181645F
timestamp start/stop: 2021-04-02 18:16:45 / 2021-04-02 18:16:58
wal start/stop: 000000020000000000000008 / 000000020000000000000008
database size: 23.4MB, database backup size: 23.4MB
repo1: backup set size: 2.8MB, backup size: 2.8MB
full backup: 20210402-181659F
timestamp start/stop: 2021-04-02 18:16:59 / 2021-04-02 18:17:15
wal start/stop: 000000020000000000000009 / 000000020000000000000009
database size: 23.4MB, database backup size: 23.4MB
repo1: backup set size: 2.8MB, backup size: 2.8MB
diff backup: 20210402-181659F_20210402-181727D
timestamp start/stop: 2021-04-02 18:17:27 / 2021-04-02 18:17:28
wal start/stop: 000000020000000000000010 / 000000020000000000000010
database size: 23.4MB, database backup size: 112.3KB
repo1: backup set size: 2.8MB, backup size: 13.3KB
backup reference list: 20210402-181659F
incr backup: 20210402-181659F_20210402-181739I
timestamp start/stop: 2021-04-02 18:17:39 / 2021-04-02 18:17:49
wal start/stop: 000000030000000000000012 / 000000030000000000000012
database size: 38.6MB, database backup size: 15.7MB
repo1: backup set size: 4.7MB, backup size: 1.9MB
backup reference list: 20210402-181659F, 20210402-181659F_20210402-181727D
diff backup: 20210402-181659F_20210402-181800D
timestamp start/stop: 2021-04-02 18:18:00 / 2021-04-02 18:18:05
wal start/stop: 000000040000000000000013 / 000000040000000000000013
database size: 31MB, database backup size: 8.2MB
repo1: backup set size: 3.8MB, backup size: 1009KB
backup reference list: 20210402-181659F
incr backup: 20210402-181659F_20210402-181817I
timestamp start/stop: 2021-04-02 18:18:17 / 2021-04-02 18:18:18
wal start/stop: 000000050000000000000015 / 000000050000000000000015
database size: 31MB, database backup size: 2.2MB
repo1: backup set size: 3.8MB, backup size: 234KB
backup reference list: 20210402-181659F, 20210402-181659F_20210402-181800Dsudo pg_ctlcluster 12 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta \
--set=20210402-181659F_20210402-181817I \
--type=time "--target=2021-04-02 18:18:08.135697+00" --target-action=promote restoresudo pg_ctlcluster 12 demo start
sudo -u postgres psql -c "select * from important_table"
ERROR: relation "important_table" does not exist
LINE 1: select * from important_table
^recovery stopping before...and
last completed transaction...log messages. If they are not present then the recovery to the specified point-in-time was not successful.
sudo -u postgres cat /var/log/postgresql/postgresql-12-demo.log
[filtered 3 lines of output] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" LOG: database system was interrupted; last known up at 2021-04-02 18:18:17 UTC
LOG: starting point-in-time recovery to 2021-04-02 18:18:08.135697+00
LOG: restored log file "00000005.history" from archive LOG: restored log file "000000050000000000000015" from archive LOG: redo starts at 0/15000028
LOG: consistent recovery state reached at 0/15000100
LOG: database system is ready to accept read only connections
LOG: redo done at 0/15000100
[filtered 7 lines of output]sudo pg_ctlcluster 12 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta \
--type=time "--target=2021-04-02 18:18:08.135697+00" \
--target-action=promote restoresudo pg_ctlcluster 12 demo start
sudo -u postgres psql -c "select * from important_table"
message ----------------
Important Data
(1 row)
recovery stopping before...and
last completed transaction...messages showing that the recovery was successful.
sudo -u postgres cat /var/log/postgresql/postgresql-12-demo.log
[filtered 5 lines of output] LOG: restored log file "00000005.history" from archive LOG: restored log file "00000006.history" from archive
LOG: starting point-in-time recovery to 2021-04-02 18:18:08.135697+00
LOG: restored log file "00000006.history" from archive
LOG: restored log file "000000040000000000000013" from archive
[filtered 4 lines of output]
LOG: database system is ready to accept read only connections
LOG: restored log file "000000050000000000000014" from archiveLOG: recovery stopping before commit of transaction 496, time 2021-04-02 18:18:16.454886+00
LOG: redo done at 0/14022440
LOG: last completed transaction was at log time 2021-04-02 18:18:06.328008+00
LOG: selected new timeline ID: 7
LOG: archive recovery complete
[filtered 2 lines of output]sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stanza-create
[filtered 2 lines of output] P00 INFO: stanza 'demo' already exists on repo1 and is valid P00 INFO: stanza-create for stanza 'demo' on repo2
P00 INFO: stanza-create command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo --repo=2 \
--log-level-console=info backupP00 INFO: backup command begin 2.33: --exec-id=1781-295a59bc --log-level-console=info --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --process-max=4 --repo=2 --repo2-azure-account=--repo2-azure-container=demo-container --repo2-azure-key= --repo1-cipher-pass= --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo1-retention-diff=2 --repo1-retention-full=2 --repo2-retention-full=4 --repo2-storage-host=blob.core.windows.net --repo2-type=azure --stanza=demo --start-fast
P00 WARN: no prior backup exists, incr backup has been changed to full
P00 INFO: execute non-exclusive pg_start_backup(): backup begins after the requested immediate checkpoint completes
P00 INFO: backup start archive = 000000070000000000000015, lsn = 0/15000028
[filtered 1279 lines of output]
P02 INFO: backup file /var/lib/postgresql/12/demo/base/1/13201 (0B, 100%)
P01 INFO: backup file /var/lib/postgresql/12/demo/base/1/13196 (0B, 100%)P00 INFO: full backup size = 31MB
P00 INFO: execute non-exclusive pg_stop_backup() and wait for all WAL segments to archive
P00 INFO: backup stop archive = 000000070000000000000015, lsn = 0/15000100
[filtered 4 lines of output]{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::demo-bucket"
],
"Condition": {
"StringEquals": {
"s3:prefix": [
"",
"demo-repo"
],
"s3:delimiter": [
"/"
]
}
}
},
{
"Effect": "Allow",
"Action": [
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::demo-bucket"
],
"Condition": {
"StringLike": {
"s3:prefix": [
"demo-repo/*"
]
}
}
},
{
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:DeleteObject"
],
"Resource": [
"arn:aws:s3:::demo-bucket/demo-repo/*"
]
}
]
}sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stanza-create
[filtered 4 lines of output] P00 INFO: stanza 'demo' already exists on repo2 and is valid P00 INFO: stanza-create for stanza 'demo' on repo3
P00 INFO: stanza-create command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo --repo=3 \
--log-level-console=info backupP00 INFO: backup command begin 2.33: --exec-id=1838-9c68bb2a --log-level-console=info --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --process-max=4 --repo=3 --repo2-azure-account=--repo2-azure-container=demo-container --repo2-azure-key= --repo1-cipher-pass= --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo3-path=/demo-repo --repo1-retention-diff=2 --repo1-retention-full=2 --repo2-retention-full=4 --repo3-retention-full=4 --repo3-s3-bucket=demo-bucket --repo3-s3-endpoint=s3.us-east-1.amazonaws.com --repo3-s3-key= --repo3-s3-key-secret= --repo3-s3-region=us-east-1 --repo2-storage-host=blob.core.windows.net --repo2-type=azure --repo3-type=s3 --stanza=demo --start-fast
P00 WARN: no prior backup exists, incr backup has been changed to full
P00 INFO: execute non-exclusive pg_start_backup(): backup begins after the requested immediate checkpoint completes
P00 INFO: backup start archive = 000000070000000000000017, lsn = 0/17000028
[filtered 1279 lines of output]
P04 INFO: backup file /var/lib/postgresql/12/demo/base/1/13201 (0B, 100%)
P02 INFO: backup file /var/lib/postgresql/12/demo/base/1/13196 (0B, 100%)P00 INFO: full backup size = 31MB
P00 INFO: execute non-exclusive pg_stop_backup() and wait for all WAL segments to archive
P00 INFO: backup stop archive = 000000070000000000000017, lsn = 0/17000100
[filtered 4 lines of output]sudo pg_ctlcluster 12 demo stop
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stop
P00 INFO: stop command begin 2.33: --exec-id=1883-2e7e48b9 --log-level-console=info --log-level-stderr=off --no-log-timestamp --stanza=demo
P00 INFO: stop command end: completed successfully
sudo -u postgres pgbackrest --stanza=demo --repo=1 \
--log-level-console=info stanza-deleteP00 INFO: stanza-delete command begin 2.33: --exec-id=1891-b34d48a4 --log-level-console=info --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --repo=1 --repo2-azure-account=--repo2-azure-container=demo-container --repo2-azure-key= --repo1-cipher-pass= --repo1-cipher-type=aes-256-cbc --repo4-gcs-bucket=demo-bucket --repo4-gcs-key= --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo3-path=/demo-repo --repo4-path=/demo-repo --repo3-s3-bucket=demo-bucket --repo3-s3-endpoint=s3.us-east-1.amazonaws.com --repo3-s3-key= --repo3-s3-key-secret= --repo3-s3-region=us-east-1 --repo2-storage-host=blob.core.windows.net --repo2-type=azure --repo3-type=s3 --repo4-type=gcs --stanza=demo
P00 INFO: stanza-delete command end: completed successfully
sudo adduser --disabled-password --gecos "" pgbackrest
sudo apt-get install postgresql-client libxml2
sudo scp build:/build/pgbackrest-release-2.33/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_keyssudo -u pgbackrest ssh postgres@pg-primary
sudo -u postgres ssh pgbackrest@repository
sudo -u pgbackrest pgbackrest --stanza=demo stanza-create
sudo -u postgres pgbackrest --stanza=demo check
sudo -u pgbackrest pgbackrest --stanza=demo check
sudo -u pgbackrest pgbackrest --stanza=demo backup
P00 WARN: no prior backup exists, incr backup has been changed to full
sudo pg_ctlcluster 12 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta restore
sudo pg_ctlcluster 12 demo start
sudo -u pgbackrest pgbackrest --stanza=demo --type=full backup
sudo -u pgbackrest pgbackrest --stanza=demo --type=full backup
sudo -u pgbackrest pgbackrest info
stanza: demo
status: ok
cipher: none
db (current)
wal archive min/max (12): 00000008000000000000001C/00000008000000000000001D
full backup: 20210402-181947Ftimestamp start/stop: 2021-04-02 18:19:47 / 2021-04-02 18:20:02
wal start/stop: 00000008000000000000001C / 00000008000000000000001C
database size: 31MB, database backup size: 31MB
repo1: backup set size: 3.7MB, backup size: 3.7MB
full backup: 20210402-182005Ftimestamp start/stop: 2021-04-02 18:20:05 / 2021-04-02 18:20:14
wal start/stop: 00000008000000000000001D / 00000008000000000000001D
database size: 31MB, database backup size: 31MB
repo1: backup set size: 3.7MB, backup size: 3.7MBsudo -u postgres pgbackrest stop
sudo -u pgbackrest pgbackrest --stanza=demo backup
P00 WARN: unable to check pg-1: [StopError] raised from remote-0 protocol on 'pg-primary': stop file exists for all stanzas
P00 ERROR: [056]: unable to find primary cluster - cannot proceed
sudo -u postgres pgbackrest stop
P00 WARN: stop file already exists for all stanzas
sudo -u postgres pgbackrest start
sudo -u postgres pgbackrest --stanza=demo stop
sudo -u pgbackrest pgbackrest --stanza=demo backup
P00 WARN: unable to check pg-1: [StopError] raised from remote-0 protocol on 'pg-primary': stop file exists for stanza demo
P00 ERROR: [056]: unable to find primary cluster - cannot proceed
sudo -u postgres pgbackrest --stanza=demo start
sudo apt-get install postgresql-client libxml2
sudo scp build:/build/pgbackrest-release-2.33/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_keyssudo -u pgbackrest ssh postgres@pg-standby
sudo -u postgres ssh pgbackrest@repository
sudo pg_createcluster 12 demo
sudo -u postgres pgbackrest --stanza=demo --delta --type=standby restore
sudo -u postgres cat /var/lib/postgresql/12/demo/postgresql.auto.conf
# Do not edit this file manually! # It will be overwritten by the ALTER SYSTEM command. # Recovery settings generated by pgBackRest restore on 2021-04-02 18:16:25 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2021-04-02 18:17:31 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2021-04-02 18:17:53 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Removed by pgBackRest restore on 2021-04-02 18:18:27 # recovery_target = 'immediate' # Removed by pgBackRest restore on 2021-04-02 18:18:27 # recovery_target_action = 'promote' # Recovery settings generated by pgBackRest restore on 2021-04-02 18:18:27 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Removed by pgBackRest restore on 2021-04-02 18:19:40 # recovery_target_time = '2021-04-02 18:18:08.135697+00' # Removed by pgBackRest restore on 2021-04-02 18:19:40 # recovery_target_action = 'promote' # Recovery settings generated by pgBackRest restore on 2021-04-02 18:19:40 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2021-04-02 18:20:39 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'
sudo pg_ctlcluster 12 demo start
sudo -u postgres cat /var/log/postgresql/postgresql-12-demo.log
[filtered 4 lines of output] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" LOG: database system was interrupted; last known up at 2021-04-02 18:20:06 UTC
LOG: entering standby mode
LOG: restored log file "00000008.history" from archive LOG: restored log file "00000008000000000000001D" from archive LOG: redo starts at 0/1D000028 LOG: consistent recovery state reached at 0/1D000138
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/1E021750 | 2021-04-02 18:20:47.501606+00 (1 row)
sudo -u postgres psql -c " \
select *, current_timestamp from replicated_table"message | current_timestamp ----------------+-------------------------------
Important Data | 2021-04-02 18:20:53.780268+00
(1 row)
sudo -u postgres pgbackrest --stanza=demo --log-level-console=info check
P00 INFO: check command begin 2.33: --exec-id=619-4f46bd96 --log-level-console=info --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --repo1-host=repository --stanza=demo P00 INFO: check repo1 (standby)
P00 INFO: switch wal not performed because this is a standby
P00 INFO: check command end: completed successfully
sudo -u postgres psql -c " \
create user replicator password 'jw8s0F4' replication";CREATE ROLE
sudo -u postgres sh -c 'echo \
"host replication replicator 172.17.0.7/32 md5" \
>> /etc/postgresql/12/demo/pg_hba.conf'sudo pg_ctlcluster 12 demo reload
sudo -u postgres sh -c 'echo \
"172.17.0.5:*:replication:replicator:jw8s0F4" \
>> /var/lib/postgresql/.pgpass'sudo -u postgres chmod 600 /var/lib/postgresql/.pgpass
sudo pg_ctlcluster 12 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta --type=standby restore
sudo -u postgres cat /var/lib/postgresql/12/demo/postgresql.auto.conf
# Do not edit this file manually! # It will be overwritten by the ALTER SYSTEM command. # Recovery settings generated by pgBackRest restore on 2021-04-02 18:16:25 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2021-04-02 18:17:31 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2021-04-02 18:17:53 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Removed by pgBackRest restore on 2021-04-02 18:18:27 # recovery_target = 'immediate' # Removed by pgBackRest restore on 2021-04-02 18:18:27 # recovery_target_action = 'promote' # Recovery settings generated by pgBackRest restore on 2021-04-02 18:18:27 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Removed by pgBackRest restore on 2021-04-02 18:19:40 # recovery_target_time = '2021-04-02 18:18:08.135697+00' # Removed by pgBackRest restore on 2021-04-02 18:19:40 # recovery_target_action = 'promote' # Recovery settings generated by pgBackRest restore on 2021-04-02 18:19:40 restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"' # Recovery settings generated by pgBackRest restore on 2021-04-02 18:20:58 primary_conninfo = 'host=172.17.0.5 port=5432 user=replicator' restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'
sudo pg_ctlcluster 12 demo start
sudo -u postgres cat /var/log/postgresql/postgresql-12-demo.log
[filtered 11 lines of output] LOG: database system is ready to accept read only connections LOG: restored log file "00000008000000000000001E" from archive
LOG: started streaming WAL from primary at 0/1F000000 on timeline 8
sudo -u postgres psql -c " \
begin; \
create table stream_table (message text); \
insert into stream_table values ('Important Data'); \
commit; \
select *, current_timestamp from stream_table";message | current_timestamp ----------------+-------------------------------
Important Data | 2021-04-02 18:21:04.923986+00
(1 row)
sudo -u postgres psql -c " \
select *, current_timestamp from stream_table"message | current_timestamp ----------------+-------------------------------
Important Data | 2021-04-02 18:21:05.599965+00
(1 row)
sudo mkdir -p -m 750 /var/spool/pgbackrest
sudo chown postgres:postgres /var/spool/pgbackrest
sudo mkdir -p -m 750 /var/spool/pgbackrest
sudo chown postgres:postgres /var/spool/pgbackrest
sudo -u postgres psql -c "alter user replicator password 'bogus'"
ALTER ROLE
sudo pg_ctlcluster 12 demo restart
looking aheadto see which WAL segments are ready to be archived beyond the request that PostgreSQL is currently making via the archive_command. WAL segments are transferred to the archive directly from the pg_xlog/pg_wal directory and success is only returned by the archive_command when the WAL segment has been safely stored in the archive.
sudo -u postgres psql -c " \
select pg_create_restore_point('test async push'); select pg_switch_wal(); \
select pg_create_restore_point('test async push'); select pg_switch_wal(); \
select pg_create_restore_point('test async push'); select pg_switch_wal(); \
select pg_create_restore_point('test async push'); select pg_switch_wal(); \
select pg_create_restore_point('test async push'); select pg_switch_wal();"sudo -u postgres pgbackrest --stanza=demo --log-level-console=info check
P00 INFO: check command begin 2.33: --exec-id=2498-55f6508c --log-level-console=info --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --repo1-host=repository --stanza=demo P00 INFO: check repo1 configuration (primary) P00 INFO: check repo1 archive for WAL (primary)
P00 INFO: WAL segment 000000080000000000000024 successfully archived to '/var/lib/pgbackrest/archive/demo/12-1/0000000800000000/000000080000000000000024-d2d34320da0a318271670bce74ba0278619236e9.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.33: [/var/lib/postgresql/12/demo/pg_wal] --archive-async --exec-id=2484-103b06fa --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --process-max=2 --repo1-host=repository --spool-path=/var/spool/pgbackrest --stanza=demo
P00 INFO: push 1 WAL file(s) to archive: 00000008000000000000001F P01 DETAIL: pushed WAL file '00000008000000000000001F' to the archive
P00 INFO: archive-push:async command end: completed successfully -------------------PROCESS START------------------- P00 INFO: archive-push:async command begin 2.33: [/var/lib/postgresql/12/demo/pg_wal] --archive-async --exec-id=2501-180ed6e9 --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --process-max=2 --repo1-host=repository --spool-path=/var/spool/pgbackrest --stanza=demo
P00 INFO: push 4 WAL file(s) to archive: 000000080000000000000020...000000080000000000000023 P01 DETAIL: pushed WAL file '000000080000000000000020' to the archive P02 DETAIL: pushed WAL file '000000080000000000000021' to the archive P01 DETAIL: pushed WAL file '000000080000000000000022' to the archive P02 DETAIL: pushed WAL file '000000080000000000000023' to the archive
P00 INFO: archive-push:async command end: completed successfully -------------------PROCESS START------------------- P00 INFO: archive-push:async command begin 2.33: [/var/lib/postgresql/12/demo/pg_wal] --archive-async --exec-id=2517-857007f9 --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --process-max=2 --repo1-host=repository --spool-path=/var/spool/pgbackrest --stanza=demo
P00 INFO: push 1 WAL file(s) to archive: 000000080000000000000024 P01 DETAIL: pushed WAL file '000000080000000000000024' 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.33: [00000008000000000000001D, 00000008000000000000001E, 00000008000000000000001F, 000000080000000000000020, 000000080000000000000021, 000000080000000000000022, 000000080000000000000023, 000000080000000000000024] --archive-async --exec-id=833-702a5b8a --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --process-max=2 --repo1-host=repository --spool-path=/var/spool/pgbackrest --stanza=demo P00 INFO: get 8 WAL file(s) from archive: 00000008000000000000001D...000000080000000000000024
P01 DETAIL: found 00000008000000000000001D in the repo1: 12-1 archive P02 DETAIL: found 00000008000000000000001E in the repo1: 12-1 archive
P00 DETAIL: unable to find 00000008000000000000001F 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.33: [00000008000000000000001F, 000000080000000000000020, 000000080000000000000021, 000000080000000000000022, 000000080000000000000023, 000000080000000000000024, 000000080000000000000025, 000000080000000000000026] --archive-async --exec-id=875-b60d4294 --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/12/demo --process-max=2 --repo1-host=repository --spool-path=/var/spool/pgbackrest --stanza=demo
P00 INFO: get 8 WAL file(s) from archive: 00000008000000000000001F...000000080000000000000026P02 DETAIL: found 000000080000000000000020 in the repo1: 12-1 archive P01 DETAIL: found 00000008000000000000001F in the repo1: 12-1 archive P02 DETAIL: found 000000080000000000000021 in the repo1: 12-1 archive P01 DETAIL: found 000000080000000000000022 in the repo1: 12-1 archive P02 DETAIL: found 000000080000000000000023 in the repo1: 12-1 archive P01 DETAIL: found 000000080000000000000024 in the repo1: 12-1 archive
P00 DETAIL: unable to find 000000080000000000000025 in the archive
P00 INFO: archive-get:async command end: completed successfully
[filtered 5 lines of output]sudo -u postgres psql -c "alter user replicator password 'jw8s0F4'"
ALTER ROLE
sudo -u pgbackrest pgbackrest --stanza=demo --log-level-console=detail backup
[filtered 2 lines of output] P00 INFO: execute non-exclusive pg_start_backup(): backup begins after the requested immediate checkpoint completes P00 INFO: backup start archive = 000000080000000000000026, lsn = 0/26000028
P00 INFO: wait for replay on the standby to reach 0/26000028 P00 INFO: replay on the standby reached 0/26000028 P01 INFO: backup file pg-primary:/var/lib/postgresql/12/demo/global/pg_control (8KB, 0%) checksum 3446588b1479fdd1c4b4f9c48d4abe948d11afe3
P03 INFO: backup file pg-standby:/var/lib/postgresql/12/demo/base/13359/1249 (440KB, 19%) checksum b66c7561f52944b428ffe219430be6be2486bdc5
P01 INFO: backup file pg-primary:/var/lib/postgresql/12/demo/pg_logical/replorigin_checkpoint (8B, 19%) checksum 347fc8f2df71bd4436e38bd1516ccd7ea0d46532
P02 INFO: backup file pg-standby:/var/lib/postgresql/12/demo/base/13359/2608 (456KB, 38%) checksum 3773f8c1d1255ffb3d1ffc4d7afb281732453eb5
P04 INFO: backup file pg-standby:/var/lib/postgresql/12/demo/base/13359/2674 (344KB, 53%) checksum b1198b74668e696bda0e590b560bb8a96aaea260
[filtered 1292 lines of output]sudo pg_ctlcluster 12 demo stop
sudo pg_ctlcluster 12 demo stop
sudo -u postgres /usr/lib/postgresql/13/bin/initdb \
-D /var/lib/postgresql/13/demo -k -A peersudo pg_createcluster 13 demo
sudo -u postgres sh -c 'cd /var/lib/postgresql && \
/usr/lib/postgresql/13/bin/pg_upgrade \
--old-bindir=/usr/lib/postgresql/12/bin \
--new-bindir=/usr/lib/postgresql/13/bin \
--old-datadir=/var/lib/postgresql/12/demo \
--new-datadir=/var/lib/postgresql/13/demo \
--old-options=" -c config_file=/etc/postgresql/12/demo/postgresql.conf" \
--new-options=" -c config_file=/etc/postgresql/13/demo/postgresql.conf"'[filtered 63 lines of output] Creating script to delete old cluster ok
Upgrade Complete
----------------
Optimizer statistics are not transferred by pg_upgrade so,
[filtered 4 lines of output]sudo cp /etc/postgresql/12/demo/pg_hba.conf \
/etc/postgresql/13/demo/pg_hba.confsudo -u postgres pgbackrest --stanza=demo --no-online \
--log-level-console=info stanza-upgradeP00 INFO: stanza-upgrade command begin 2.33: --exec-id=2890-22c5d503 --log-level-console=info --log-level-file=detail --log-level-stderr=off --no-log-timestamp --no-online --pg1-path=/var/lib/postgresql/13/demo --repo1-host=repository --stanza=demo P00 INFO: stanza-upgrade for stanza 'demo' on repo1
P00 INFO: stanza-upgrade command end: completed successfully
sudo pg_ctlcluster 13 demo start
sudo -u postgres pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file 12 demo 5432 down postgres /var/lib/postgresql/12/demo /var/log/postgresql/postgresql-12-demo.log 13 demo 5432 online postgres /var/lib/postgresql/13/demo /var/log/postgresql/postgresql-13-demo.log
sudo -u postgres pgbackrest --stanza=demo check
sudo pg_dropcluster 12 demo
sudo pg_dropcluster 12 demo
sudo pg_createcluster 13 demo
sudo -u pgbackrest pgbackrest --stanza=demo check
P00 WARN: unable to check pg-2: [DbConnectError] raised from remote-0 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 "/var/run/postgresql/.s.PGSQL.5432"?sudo -u pgbackrest pgbackrest --stanza=demo --type=full backup
sudo -u postgres pgbackrest --stanza=demo --delta --type=standby restore
sudo pg_ctlcluster 13 demo start
sudo -u postgres pgbackrest --stanza=demo check