Skip to content

Commit f725966

Browse files
committed
minor cleanup before 2.2.0 release
1 parent 5c4ad52 commit f725966

File tree

3 files changed

+148
-32
lines changed

3 files changed

+148
-32
lines changed

Documentation.md

Lines changed: 131 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ Current version - 2.2.0
1717
* [Setting up Continuous WAL Archiving](#setting-up-continuous-wal-archiving)
1818
* [Setting up Backup from Standby](#setting-up-backup-from-standby)
1919
* [Setting up Cluster Verification](#setting-up-cluster-verification)
20-
* [Setting up PTRACK Backups](#setting-up-ptrack-backups)
2120
* [Setting up Partial Restore](#setting-up-partial-restore)
2221
* [Configuring the Remote Mode](#configuring-the-remote-mode)
22+
* [Setting up PTRACK Backups](#setting-up-ptrack-backups)
2323

2424
5. [Usage](#usage)
2525
* [Creating a Backup](#creating-a-backup)
@@ -73,10 +73,13 @@ Current version - 2.2.0
7373
* [Archiving Options](#archiving-options)
7474
* [Remote Mode Options](#remote-mode-options)
7575
* [Remote WAL Archive Options](#remote-wal-archive-options)
76+
* [Partial Restore Options](#partial-restore-options)
7677
* [Replica Options](#replica-options)
7778

78-
7. [Authors](#authors)
79-
8. [Credits](#credits)
79+
7. [HOWTO](#howto)
80+
* [Minimal setup](#minimal-setup)
81+
8. [Authors](#authors)
82+
9. [Credits](#credits)
8083

8184

8285
## Synopsis
@@ -135,7 +138,7 @@ As compared to other backup solutions, pg_probackup offers the following benefit
135138
- Backup from replica: avoid extra load on the master server by taking backups from a standby
136139
- External directories: add to backup content of directories located outside of the PostgreSQL data directory (PGDATA), such as scripts, configs, logs and pg_dump files
137140
- Backup Catalog: get list of backups and corresponding meta information in `plain` or `json` formats and view WAL Archive information.
138-
- Partial Restore: restore the only specified databases or skip the specified databases.
141+
- Partial Restore: restore only the specified databases or skip the specified databases.
139142

140143
To manage backup data, pg_probackup creates a `backup catalog`. This is a directory that stores all backup files with additional meta information, as well as WAL archives required for point-in-time recovery. You can store backups for different instances in separate subdirectories of a single backup catalog.
141144

@@ -280,7 +283,7 @@ Since pg_probackup needs to read cluster files directly, pg_probackup must be st
280283

281284
Depending on whether you are plan to take [autonomous](#stream-mode) and/or [archive](#archive-mode) backups, PostgreSQL cluster configuration will differ, as specified in the sections below. To back up the database cluster from a standby server, run pg_probackup in remote mode or create PTRACK backups, additional setup is required.
282285

283-
For details, see the sections [Setting up STREAM Backups](#setting-up-stream-backups), [Setting up continuous WAL archiving](#setting-up-continuous-wal-archiving), [Setting up Backup from Standby](#setting-up-backup-from-standby), [Configuring the Remote Mode](#configuring-the-remote-mode) and [Setting up PTRACK Backups](#setting-up-ptrack-backups).
286+
For details, see the sections [Setting up STREAM Backups](#setting-up-stream-backups), [Setting up continuous WAL archiving](#setting-up-continuous-wal-archiving), [Setting up Backup from Standby](#setting-up-backup-from-standby), [Configuring the Remote Mode](#configuring-the-remote-mode), [Setting up Partial Restore](#setting-up-partial-restore) and [Setting up PTRACK Backups](#setting-up-ptrack-backups).
284287

285288
### Setting up STREAM Backups
286289

@@ -356,19 +359,13 @@ GRANT EXECUTE ON FUNCTION bt_index_check(oid) TO backup;
356359
GRANT EXECUTE ON FUNCTION bt_index_check(oid, bool) TO backup;
357360
```
358361

359-
### Setting up PTRACK Backups
360-
361-
Backup mode PTACK can be used only on Postgrespro Standart and Postgrespro Enterprise installations or patched vanilla PostgreSQL. Links to ptrack patches can be found [here](https://github.com/postgrespro/pg_probackup#ptrack-support).
362+
### Setting up Partial Restore
362363

363-
If you are going to use PTRACK backups, complete the following additional steps:
364-
365-
- Set the parameter `ptrack_enable` to `on`.
366-
- Grant the rights to execute `ptrack` functions to the *backup* role **in every database** of the cluster:
364+
If you are plalling to use partial restore, complete the following additional step:
367365

368-
GRANT EXECUTE ON FUNCTION pg_catalog.pg_ptrack_clear() TO backup;
369-
GRANT EXECUTE ON FUNCTION pg_catalog.pg_ptrack_get_and_clear(oid, oid) TO backup;
366+
- Grant the read-only acces to 'pg_catalog.pg_database' to the *backup* role only in database **used for connection** to PostgreSQL server:
370367

371-
- The *backup* role must have access to all the databases of the cluster.
368+
GRANT SELECT ON TABLE pg_catalog.pg_database TO backup;
372369

373370
### Configuring the Remote Mode
374371

@@ -408,6 +405,20 @@ pg_probackup in remote mode via `ssh` works as follows:
408405

409406
>NOTE: You can improse [additional restrictions](https://man.openbsd.org/OpenBSD-current/man8/sshd.8#AUTHORIZED_KEYS_FILE_FORMAT) on ssh settings to protect the system in the event of account compromise.
410407
408+
### Setting up PTRACK Backups
409+
410+
Backup mode PTACK can be used only on Postgrespro Standart and Postgrespro Enterprise installations or patched vanilla PostgreSQL. Links to ptrack patches can be found [here](https://github.com/postgrespro/pg_probackup#ptrack-support).
411+
412+
If you are going to use PTRACK backups, complete the following additional steps:
413+
414+
- Set the parameter `ptrack_enable` to `on`.
415+
- Grant the rights to execute `ptrack` functions to the *backup* role **in every database** of the cluster:
416+
417+
GRANT EXECUTE ON FUNCTION pg_catalog.pg_ptrack_clear() TO backup;
418+
GRANT EXECUTE ON FUNCTION pg_catalog.pg_ptrack_get_and_clear(oid, oid) TO backup;
419+
420+
- The *backup* role must have access to all the databases of the cluster.
421+
411422
## Usage
412423

413424
### Creating a Backup
@@ -1821,6 +1832,111 @@ Deprecated. User name to connect as.
18211832
Default: 300 sec
18221833
Deprecated. Wait time for WAL segment streaming via replication, in seconds. By default, pg_probackup waits 300 seconds. You can also define this parameter in the pg_probackup.conf configuration file using the [set-config](#set-config) command.
18231834

1835+
## Howto
1836+
1837+
All exaples below assume the remote mode of operations via `ssh`. If you are planning to run backup and restore operation locally then step `Setup passwordless SSH connection` can be skipped and all `--remote-*` options can be ommited.
1838+
1839+
Examples are based on Ubuntu 18.04, PostgreSQL 11 and pg_probackup 2.2.0.
1840+
1841+
backup_host - host with backup catalog.
1842+
backupman - user on `backup_host` running all pg_probackup operations.
1843+
/mnt/backups - directory on `backup_host` where backup catalog is stored.
1844+
1845+
postgres_host - host with PostgreSQL cluster.
1846+
postgres - user on `postgres_host` which run PostgreSQL cluster.
1847+
/var/lib/postgresql/11/main - directory on `postgres_host` where PGDATA of PostgreSQL cluster is located.
1848+
backup_db - database used for connection to PostgreSQL cluster.
1849+
1850+
### Minimal Setup
1851+
1852+
This setup is relying on autonomous FULL and DELTA backups.
1853+
1854+
1. Setup passwordless SSH connection from `backup_host` to `postgres_host`:
1855+
```
1856+
[backupman@backup_host] ssh-copy-id postgres@postgres_host
1857+
```
1858+
1859+
2. Setup PostgreSQL cluster.
1860+
2.1. It is recommended from security purposes to use separate database for backup operations.
1861+
```
1862+
postgres=#
1863+
CREATE DATABASE backupdb;
1864+
```
1865+
1866+
2.2. Connect to `backupdb` database, create role `probackup` and grant to it the following permissions:
1867+
```
1868+
backupdb=#
1869+
BEGIN;
1870+
CREATE ROLE probackup WITH LOGIN REPLICATION;
1871+
GRANT USAGE ON SCHEMA pg_catalog TO probackup;
1872+
GRANT EXECUTE ON FUNCTION pg_catalog.current_setting(text) TO probackup;
1873+
GRANT EXECUTE ON FUNCTION pg_catalog.pg_is_in_recovery() TO probackup;
1874+
GRANT EXECUTE ON FUNCTION pg_catalog.pg_start_backup(text, boolean, boolean) TO probackup;
1875+
GRANT EXECUTE ON FUNCTION pg_catalog.pg_stop_backup(boolean, boolean) TO probackup;
1876+
GRANT EXECUTE ON FUNCTION pg_catalog.pg_create_restore_point(text) TO probackup;
1877+
GRANT EXECUTE ON FUNCTION pg_catalog.pg_switch_wal() TO probackup;
1878+
GRANT EXECUTE ON FUNCTION pg_catalog.pg_last_wal_replay_lsn() TO probackup;
1879+
GRANT EXECUTE ON FUNCTION pg_catalog.txid_current() TO probackup;
1880+
GRANT EXECUTE ON FUNCTION pg_catalog.txid_current_snapshot() TO probackup;
1881+
GRANT EXECUTE ON FUNCTION pg_catalog.txid_snapshot_xmax(txid_snapshot) TO probackup;
1882+
COMMIT;
1883+
```
1884+
1885+
3. Init backup catalog:
1886+
```
1887+
[backupman@backup_host]$ pg_probackup-11 init -B /mnt/backups
1888+
INFO: Backup catalog '/mnt/backups' successfully inited
1889+
```
1890+
1891+
4. Add instance 'pg-11' to backup catalog:
1892+
```
1893+
[backupman@backup_host]$ pg_probackup-11 add-instance -B /mnt/backups --instance 'pg-11' --remote-host=postgres_host --remote-user=postgres -D /var/lib/postgresql/11/main
1894+
INFO: Instance 'node' successfully inited
1895+
```
1896+
1897+
5. Take FULL backup:
1898+
```
1899+
[backupman@backup_host] pg_probackup-11 backup -B /mnt/backups --instance 'pg-11' -b FULL --stream --remote-host=postgres_host --remote-user=postgres -U probackup -d backupdb
1900+
INFO: Backup start, pg_probackup version: 2.2.0, instance: node, backup ID: PZ4LFC, backup mode: FULL, wal mode: STREAM, remote: true, compress-algorithm: none, compress-level: 1
1901+
INFO: Start transferring data files
1902+
INFO: Data files are transferred
1903+
INFO: wait for pg_stop_backup()
1904+
INFO: pg_stop backup() successfully executed
1905+
INFO: Validating backup PZ4LFC
1906+
INFO: Backup PZ4LFC data files are valid
1907+
INFO: Backup PZ4LFC resident size: 62MB
1908+
INFO: Backup PZ4LFC completed
1909+
```
1910+
1911+
6. Lets take a look at the backup catalog:
1912+
```
1913+
BACKUP INSTANCE 'pg-11'
1914+
==================================================================================================================================
1915+
Instance Version ID Recovery Time Mode WAL Mode TLI Time Data WAL Zratio Start LSN Stop LSN Status
1916+
==================================================================================================================================
1917+
node 11 PZ4LFC 2019-10-10 00:09:17+03 FULL STREAM 1/0 7s 30MB 32MB 1.00 0/C000028 0/C000160 OK
1918+
1919+
```
1920+
1921+
7. Lets hide some options into config, so cmdline can be less crowdy:
1922+
```
1923+
[backupman@backup_host]$ pg_probackup-11 set-config -B /mnt/backups --instance pg-11 --remote-host=postgres_host --remote-user=postgres --pguser=probackup --pgdatabase=backupdb
1924+
```
1925+
1926+
8. Take incremental backup in DELTA mode:
1927+
```
1928+
[backupman@backup_host] pg_probackup-11 backup -B /mnt/backups --instance 'pg-11' -b delta --stream
1929+
```
1930+
1931+
1932+
1933+
####
1934+
1935+
### Setup with WAL archive
1936+
1937+
The fact of having an WAL archive dramatically improve you scope of options toward backup and restore operations.
1938+
1939+
18241940
## Authors
18251941
Postgres Professional, Moscow, Russia.
18261942

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ gen_probackup_project.pl C:\path_to_postgresql_source_tree
114114

115115
Currently the latest documentation can be found at [github](https://postgrespro.github.io/pg_probackup).
116116
Slightly outdated documentation can be found at [Postgres Pro Enterprise documentation](https://postgrespro.com/docs/postgrespro/current/app-pgprobackup).
117-
Documentation for current devel can also be found at [github](https://github.com/postgrespro/pg_probackup/blob/master/Documentation.md)
117+
Documentation for current devel can also be found at [github](https://github.com/postgrespro/pg_probackup/blob/master/Documentation.md).
118118

119119
## License
120120

src/help.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ help_backup(void)
321321
printf(_(" retention policy after successful backup completion\n"));
322322
printf(_(" --merge-expired merge backups expired according to current\n"));
323323
printf(_(" retention policy after successful backup completion\n"));
324-
printf(_(" --delete-wal remove redundant wal files in WAL archive\n"));
324+
printf(_(" --delete-wal remove redundant files in WAL archive\n"));
325325
printf(_(" --retention-redundancy=retention-redundancy\n"));
326326
printf(_(" number of full backups to keep; 0 disables; (default: 0)\n"));
327327
printf(_(" --retention-window=retention-window\n"));
@@ -344,13 +344,13 @@ help_backup(void)
344344
printf(_(" level of compression [0-9] (default: 1)\n"));
345345

346346
printf(_("\n Archive options:\n"));
347-
printf(_(" --archive-timeout=timeout wait timeout for WAL segment archiving (default: 5min)\n"));
347+
printf(_(" --archive-timeout=timeout wait timeout for WAL segment archiving (default: 5min)\n"));
348348

349349
printf(_("\n Connection options:\n"));
350-
printf(_(" -U, --username=USERNAME user name to connect as (default: current local user)\n"));
351-
printf(_(" -d, --dbname=DBNAME database to connect (default: username)\n"));
352-
printf(_(" -h, --host=HOSTNAME database server host or socket directory(default: 'local socket')\n"));
353-
printf(_(" -p, --port=PORT database server port (default: 5432)\n"));
350+
printf(_(" -U, --pguser=USERNAME user name to connect as (default: current local user)\n"));
351+
printf(_(" -d, --pgdatabase=DBNAME database to connect (default: username)\n"));
352+
printf(_(" -h, --pghost=HOSTNAME database server host or socket directory(default: 'local socket')\n"));
353+
printf(_(" -p, --pgport=PORT database server port (default: 5432)\n"));
354354
printf(_(" -w, --no-password never prompt for password\n"));
355355
printf(_(" -W, --password force password prompt\n"));
356356

@@ -568,10 +568,10 @@ help_checkdb(void)
568568
printf(_(" available units: 'ms', 's', 'min', 'h', 'd' (default: min)\n"));
569569

570570
printf(_("\n Connection options:\n"));
571-
printf(_(" -U, --username=USERNAME user name to connect as (default: current local user)\n"));
572-
printf(_(" -d, --dbname=DBNAME database to connect (default: username)\n"));
573-
printf(_(" -h, --host=HOSTNAME database server host or socket directory(default: 'local socket')\n"));
574-
printf(_(" -p, --port=PORT database server port (default: 5432)\n"));
571+
printf(_(" -U, --pguser=USERNAME user name to connect as (default: current local user)\n"));
572+
printf(_(" -d, --pgdatabase=DBNAME database to connect (default: username)\n"));
573+
printf(_(" -h, --pghost=HOSTNAME database server host or socket directory(default: 'local socket')\n"));
574+
printf(_(" -p, --pgport=PORT database server port (default: 5432)\n"));
575575
printf(_(" -w, --no-password never prompt for password\n"));
576576
printf(_(" -W, --password force password prompt\n\n"));
577577
}
@@ -611,7 +611,7 @@ help_delete(void)
611611
printf(_(" retention policy\n"));
612612
printf(_(" --merge-expired merge backups expired according to current\n"));
613613
printf(_(" retention policy\n"));
614-
printf(_(" --delete-wal remove redundant wal files in WAL archive\n"));
614+
printf(_(" --delete-wal remove redundant files in WAL archive\n"));
615615
printf(_(" --retention-redundancy=retention-redundancy\n"));
616616
printf(_(" number of full backups to keep; 0 disables; (default: 0)\n"));
617617
printf(_(" --retention-window=retention-window\n"));
@@ -767,13 +767,13 @@ help_set_config(void)
767767
printf(_(" level of compression [0-9] (default: 1)\n"));
768768

769769
printf(_("\n Archive options:\n"));
770-
printf(_(" --archive-timeout=timeout wait timeout for WAL segment archiving (default: 5min)\n"));
770+
printf(_(" --archive-timeout=timeout wait timeout for WAL segment archiving (default: 5min)\n"));
771771

772772
printf(_("\n Connection options:\n"));
773-
printf(_(" -U, --username=USERNAME user name to connect as (default: current local user)\n"));
774-
printf(_(" -d, --dbname=DBNAME database to connect (default: username)\n"));
775-
printf(_(" -h, --host=HOSTNAME database server host or socket directory(default: 'local socket')\n"));
776-
printf(_(" -p, --port=PORT database server port (default: 5432)\n"));
773+
printf(_(" -U, --pguser=USERNAME user name to connect as (default: current local user)\n"));
774+
printf(_(" -d, --pgdatabase=DBNAME database to connect (default: username)\n"));
775+
printf(_(" -h, --pghost=HOSTNAME database server host or socket directory(default: 'local socket')\n"));
776+
printf(_(" -p, --pgport=PORT database server port (default: 5432)\n"));
777777

778778
printf(_("\n Remote options:\n"));
779779
printf(_(" --remote-proto=protocol remote protocol to use\n"));

0 commit comments

Comments
 (0)