FOSDEM PostgreSQL Devroom
Stefan Fercot
(2 February 2020)
Support |
Training |
Advice |
$ pgbackrest --stanza=my_stanza stanza-create
P00 INFO: stanza-create command begin 2.23: ...
P00 INFO: stanza-create command end: completed successfully
$ pgbackrest --stanza=my_stanza check
P00 INFO: check command begin 2.23: ...
P00 INFO: WAL segment 000000010000000000000001 successfully archived to ...
P00 INFO: check command end: completed successfully
$ pgbackrest --stanza=my_stanza --type=full backup
P00 INFO: backup command begin 2.23: ...
P00 INFO: execute non-exclusive pg_start_backup() with label "...":
backup begins after the requested immediate checkpoint completes
P00 INFO: backup start archive = 000000010000000000000003, lsn = 0/3000060
P00 INFO: full backup size = 24.2MB
P00 INFO: execute non-exclusive pg_stop_backup() and wait for all WAL segments
to archive
P00 INFO: backup stop archive = 000000010000000000000003, lsn = 0/3000138
P00 INFO: new backup label = 20200131-150158F
P00 INFO: backup command end: completed successfully
P00 INFO: expire command begin 2.23: ...
P00 INFO: expire command end: completed successfully
$ pgbackrest --stanza=my_stanza --type=diff backup
P00 INFO: backup command begin 2.23: ...
P00 INFO: last backup label = 20200131-150158F, version = 2.23
P00 INFO: execute non-exclusive pg_start_backup() with label "...":
backup begins after the requested immediate checkpoint completes
P00 INFO: backup start archive = 000000010000000000000005, lsn = 0/5000028
P00 INFO: diff backup size = 24.2MB
P00 INFO: execute non-exclusive pg_stop_backup() and wait for all WAL segments
to archive
P00 INFO: backup stop archive = 000000010000000000000005, lsn = 0/5000138
P00 INFO: new backup label = 20200131-150158F_20200131-150245D
P00 INFO: backup command end: completed successfully
P00 INFO: expire command begin 2.23: ...
P00 INFO: expire command end: completed successfully
$ pgbackrest --stanza=my_stanza --type=incr backup
P00 INFO: backup command begin 2.23: ...
P00 INFO: last backup label = 20200131-150158F_20200131-150245D, version = 2.23
P00 INFO: execute non-exclusive pg_start_backup() with label "...":
backup begins after the requested immediate checkpoint completes
P00 INFO: backup start archive = 000000010000000000000007, lsn = 0/7000028
P00 INFO: incr backup size = 24.2MB
P00 INFO: execute non-exclusive pg_stop_backup() and wait for all WAL segments
to archive
P00 INFO: backup stop archive = 000000010000000000000007, lsn = 0/7000138
P00 INFO: new backup label = 20200131-150158F_20200131-150410I
P00 INFO: backup command end: completed successfully
P00 INFO: expire command begin 2.23: ...
P00 INFO: expire command end: completed successfully
INFO
command$ pgbackrest info --stanza=my_stanza
stanza: my_stanza
status: ok
cipher: none
db (current)
wal archive min/max (12-1): 000000010000000000000003/000000010000000000000007
full backup: 20200131-150158F
timestamp start/stop: 2020-01-31 15:01:58 / 2020-01-31 15:02:14
wal start/stop: 000000010000000000000003 / 000000010000000000000003
database size: 24.2MB, backup size: 24.2MB
repository size: 2.9MB, repository backup size: 2.9MB
...
--repo-type
Repository Type Option (--repo-type)
Type of storage used for the repository.
The following repository types are supported:
cifs - Like posix, but disables links and directory fsyncs
posix - Posix-compliant file systems
s3 - AWS Simple Storage Service
Be careful with CIFS !
[global]
repo1-host=backup-srv
repo1-host-user=postgres
...
[my_stanza]
pg1-path=/var/lib/pgsql/12/data
archive_command
$ sudo yum install nagios-plugins-pgbackrest-1.7-1.noarch.rpm
#===============================================================================
Package Repository
#===============================================================================
Installing:
nagios-plugins-pgbackrest nagios-plugins-pgbackrest-1.7-1.noarch
Installing for dependencies:
nagios-common epel
nagios-plugins epel
perl-IO-Tty base
perl-JSON base
perl-Net-SFTP-Foreign epel
perl-Sort-Key epel
#===============================================================================
--retention-full
--retention-age
--retention-age-to-full
--retention-full
--output=human
$ check_pgbackrest --stanza=my_stanza
--service=retention --retention-full=1 --output=human
Service : BACKUPS_RETENTION
Returns : 0 (OK)
Message : backups policy checks ok
Long message : full=1
Long message : diff=1
Long message : incr=1
Long message : latest=incr,20200131-150158F_20200131-150410I
Long message : latest_age=2m24s
$ check_pgbackrest --stanza=my_stanza
--service=retention --retention-full=1 --output=human
--retention-age=24h --retention-age-to-full=7d
Service : BACKUPS_RETENTION
Returns : 0 (OK)
Message : backups policy checks ok
Long message : full=1
Long message : diff=1
Long message : incr=1
Long message : latest=incr,20200131-150158F_20200131-150410I
Long message : latest_age=2m47s
Long message : latest_full=20200131-150158F
Long message : latest_full_age=5m
Only based on pgbackrest info
output!
pgbackrest info
command
--wal-segsize=size
Check for each segment, wal after wal!
--output=human
$ check_pgbackrest --stanza=my_stanza
--service=archives --repo-path=/var/lib/pgbackrest/archive --output=human
Service : WAL_ARCHIVES
Returns : 0 (OK)
Message : 81 WAL archived
Message : latest archived since 1m59s
Long message : latest_archive_age=1m59s
Long message : num_archives=81
Long message : archives_dir=/var/lib/pgbackrest/archive/my_stanza/12-1
Long message : min_wal=000000010000000000000003
Long message : max_wal=000000010000000000000053
Long message : oldest_archive=000000010000000000000003
Long message : latest_archive=000000010000000000000053
Long message : latest_bck_archive_start=000000010000000000000007
Long message : latest_bck_type=incr
$ rm -rf [...]/archive/my_stanza/12-1/0000000100000000/00000001000000000000001*
$ pgbackrest info --stanza=my_stanza
stanza: my_stanza
status: ok
cipher: none
db (current)
wal archive min/max (12-1): 000000010000000000000003/000000010000000000000053
...
pgBackRest doesn’t report any error!
$ check_pgbackrest --stanza=my_stanza
--service=archives --repo-path=/var/lib/pgbackrest/archive --output=human
Service : WAL_ARCHIVES
Returns : 2 (CRITICAL)
Message : wrong sequence or missing file @ '000000010000000000000010'
...
Message : wrong sequence or missing file @ '00000001000000000000001F'
...
Long message : min_wal=000000010000000000000003
Long message : max_wal=000000010000000000000053
Long message : oldest_archive=000000010000000000000003
Long message : latest_archive=000000010000000000000053
Long message : latest_bck_archive_start=000000010000000000000007
Long message : latest_bck_type=incr
latest_bck_archive_start
--repo-host
and --repo-host-user
Net::SFTP::Foreign
--repo-host
, --repo-host-user
repo1-s3-key
and repo1-s3-key-secret
Config::IniFiles
Net::Amazon::S3
--repo-s3
, --repo-s3-over-http
--ignore-archived-before
--ignore-archived-after
--latest-archive-age-alert
icinga-srv
executes check_pgbackrest
commands through SSH with Icinga 2pgsql-srv
stores the PostgreSQL cluster to backup with pgBackRestbackup-srv
stores the CIFS shareicinga-srv
executes check_pgbackrest
commands through SSH with Icinga 2pgsql-srv
stores the PostgreSQL cluster to backup with pgBackRestbackup-srv
stores the pgBackRest backups and archivesbackup-srv
icinga-srv
executes check_pgbackrest
commands through SSH with Icinga 2pgsql-srv
stores the PostgreSQL cluster to backup with pgBackRestbackup-srv
stores the MinIO serverpgbackrest ls
command
mtime
available since 2.21cat
command for the .history
files$ pgbackrest help ls
pgBackRest 2.23 - 'ls' command help
List paths/files in the repository.
This is intended to be a general purpose list function, but for now it only
works on the repository.
Command Options:
--filter filter output with a regular expression
--output output format [default=text]
--recurse include all subpaths in output [default=n]
--sort sort output ascending, descending, or none
[default=asc]
.deb
package ?renesepp
)