You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR merges some updates for pgBackRest:
- Minor introduction update
- Add explanations for the configuration file parameters in a Where description, including default port mentions and explanations for each setting
- Update pg-host SRV_NAME to proper host name based on NODE number in the stanza
Copy file name to clipboardExpand all lines: docs/solutions/pgbackrest.md
+46-37Lines changed: 46 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,16 @@
1
1
# pgBackRest setup
2
2
3
-
[pgBackRest :octicons-link-external-16:](https://pgbackrest.org/) is a backup tool used to perform PostgreSQL database backup, archiving, restoration, and point-in-time recovery.
3
+
[pgBackRest :octicons-link-external-16:](https://pgbackrest.org/) is a tool used to perform PostgreSQL database backups, archiving, restoration, and point-in-time recovery.
4
4
5
-
In our solution we deploy a [pgBackRest server on a dedicated host :octicons-link-external-16:](https://pgbackrest.org/user-guide-rhel.html#repo-host) and also deploy pgBackRest on the PostgreSQL servers. Them we configure PostgreSQL servers to use it for backups and archiving.
6
-
7
-
You also need a backup storage to store the backups. It can either be a remote storage such as AWS S3, S3-compatible storages or Azure blob storage, or a filesystem-based one.
5
+
In this solution, a [pgBackRest server on a dedicated host :octicons-link-external-16:](https://pgbackrest.org/user-guide-rhel.html#repo-host) is deployed. pgBackRest is also installed and configured on the PostgreSQL servers to perform backups and manage WAL archiving.
8
6
9
7
## Preparation
10
8
11
9
Make sure to complete the [initial setup](ha-init-setup.md) steps.
12
10
13
11
## Install pgBackRest
14
12
15
-
Install pgBackRest on the following nodes: `node1`, `node2`, `node3`, `backup`
13
+
Install pgBackRest on all nodes: `node1`, `node2`, `node3`, and `backup`.
16
14
17
15
=== ":material-debian: On Debian/Ubuntu"
18
16
@@ -42,7 +40,7 @@ Do the following steps on the `backup` node.
42
40
export CA_PATH="/etc/ssl/certs/pg_ha"
43
41
```
44
42
45
-
2. Create the `pgBackRest` repository, *if necessary*
43
+
2. Create the `pgBackRest` repository, *if necessary*.
46
44
47
45
A repository is where `pgBackRest` stores backups. In this example, the backups will be saved to `/var/lib/pgbackrest`.
48
46
@@ -118,8 +116,8 @@ Do the following steps on the `backup` node.
118
116
pg1-port=5432
119
117
pg1-path=/var/lib/postgresql/{{pgversion}}/main
120
118
pg1-host-type=tls
121
-
pg1-host-cert-file=${CA_PATH}/${SRV_NAME}.crt
122
-
pg1-host-key-file=${CA_PATH}/${SRV_NAME}.key
119
+
pg1-host-cert-file=${CA_PATH}/${NODE1_NAME}.crt
120
+
pg1-host-key-file=${CA_PATH}/${NODE1_NAME}.key
123
121
pg1-host-ca-file=${CA_PATH}/ca.crt
124
122
pg1-socket-path=/var/run/postgresql
125
123
@@ -128,8 +126,8 @@ Do the following steps on the `backup` node.
128
126
pg2-port=5432
129
127
pg2-path=/var/lib/postgresql/{{pgversion}}/main
130
128
pg2-host-type=tls
131
-
pg2-host-cert-file=${CA_PATH}/${SRV_NAME}.crt
132
-
pg2-host-key-file=${CA_PATH}/${SRV_NAME}.key
129
+
pg2-host-cert-file=${CA_PATH}/${NODE2_NAME}.crt
130
+
pg2-host-key-file=${CA_PATH}/${NODE2_NAME}.key
133
131
pg2-host-ca-file=${CA_PATH}/ca.crt
134
132
pg2-socket-path=/var/run/postgresql
135
133
@@ -138,8 +136,8 @@ Do the following steps on the `backup` node.
138
136
pg3-port=5432
139
137
pg3-path=/var/lib/postgresql/{{pgversion}}/main
140
138
pg3-host-type=tls
141
-
pg3-host-cert-file=${CA_PATH}/${SRV_NAME}.crt
142
-
pg3-host-key-file=${CA_PATH}/${SRV_NAME}.key
139
+
pg3-host-cert-file=${CA_PATH}/${NODE3_NAME}.crt
140
+
pg3-host-key-file=${CA_PATH}/${NODE3_NAME}.key
143
141
pg3-host-ca-file=${CA_PATH}/ca.crt
144
142
pg3-socket-path=/var/run/postgresql
145
143
@@ -200,8 +198,8 @@ Do the following steps on the `backup` node.
200
198
pg1-port=5432
201
199
pg1-path=/var/lib/postgresql/{{pgversion}}/main
202
200
pg1-host-type=tls
203
-
pg1-host-cert-file=${CA_PATH}/${SRV_NAME}.crt
204
-
pg1-host-key-file=${CA_PATH}/${SRV_NAME}.key
201
+
pg1-host-cert-file=${CA_PATH}/${NODE1_NAME}.crt
202
+
pg1-host-key-file=${CA_PATH}/${NODE1_NAME}.key
205
203
pg1-host-ca-file=${CA_PATH}/ca.crt
206
204
pg1-socket-path=/var/run/postgresql
207
205
@@ -210,8 +208,8 @@ Do the following steps on the `backup` node.
210
208
pg2-port=5432
211
209
pg2-path=/var/lib/postgresql/{{pgversion}}/main
212
210
pg2-host-type=tls
213
-
pg2-host-cert-file=${CA_PATH}/${SRV_NAME}.crt
214
-
pg2-host-key-file=${CA_PATH}/${SRV_NAME}.key
211
+
pg2-host-cert-file=${CA_PATH}/${NODE2_NAME}.crt
212
+
pg2-host-key-file=${CA_PATH}/${NODE2_NAME}.key
215
213
pg2-host-ca-file=${CA_PATH}/ca.crt
216
214
pg2-socket-path=/var/run/postgresql
217
215
@@ -220,20 +218,32 @@ Do the following steps on the `backup` node.
220
218
pg3-port=5432
221
219
pg3-path=/var/lib/postgresql/{{pgversion}}/main
222
220
pg3-host-type=tls
223
-
pg3-host-cert-file=${CA_PATH}/${SRV_NAME}.crt
224
-
pg3-host-key-file=${CA_PATH}/${SRV_NAME}.key
221
+
pg3-host-cert-file=${CA_PATH}/${NODE3_NAME}.crt
222
+
pg3-host-key-file=${CA_PATH}/${NODE3_NAME}.key
225
223
pg3-host-ca-file=${CA_PATH}/ca.crt
226
224
pg3-socket-path=/var/run/postgresql
227
225
228
226
" | sudo tee /etc/pgbackrest.conf
229
227
```
230
228
231
-
*NOTE*: The option `backup-standby=y` above indicates the backups should be taken from a standby server. If you are operating with a primary only, or if your secondaries are not configured with `pgBackRest`, set this option to `n`.
229
+
Where:
230
+
231
+
* `pgX-host` specifies the hostname of the PostgreSQL node
232
+
* `pgX-host-port` specifies the port used by the pgBackRest server daemon on that node. The default pgBackRest server port is `8432`
233
+
* `pgX-port` specifies the PostgreSQL server port (default `5432`)
234
+
* `pgX-path` specifies the PostgreSQL data directory on the node
235
+
236
+
The `pgX` prefix is repeated for each PostgreSQL node in the cluster (for example `pg1`, `pg2`, `pg3`).
237
+
238
+
The numbering (`pg1`, `pg2`, `pg3`) represents individual PostgreSQL nodes defined in the cluster stanza.
239
+
240
+
!!! note
241
+
The option `backup-standby=y` above indicates the backups should be taken from a standby server. If you are operating with a primary only, or if your secondaries are not configured with `pgBackRest`, set this option to `n`.
232
242
233
243
### Create the certificate files
234
244
235
245
Run the following commands as a root user or with `sudo` privileges
236
-
246
+
237
247
1. Create the folder to store the certificates:
238
248
239
249
```{.bash data-prompt="$"}
@@ -252,21 +262,21 @@ Run the following commands as a root user or with `sudo` privileges
9. If you are using Patroni, change its configuration to use `pgBackRest` for archiving and restoring WAL files. Run this command only on one node, for example, on `node1`:
480
+
9. If you are using Patroni, change its configuration to use `pgBackRest` for archiving and restoring WAL files. Run this command only on one node, for example, on `node1`:
@@ -504,7 +513,6 @@ Run the following commands on `node1`, `node2`, and `node3`.
504
513
ttl: 30
505
514
```
506
515
507
-
508
516
11. Reload the changed configurations. Provide the cluster name or the node name for the following command. In our example we use the `cluster_1` cluster name:
509
517
510
518
```{.bash data-prompt="$"}
@@ -513,7 +521,8 @@ Run the following commands on `node1`, `node2`, and `node3`.
513
521
514
522
It may take a while to reload the new configuration.
515
523
516
-
*NOTE*: When configuring a PostgreSQL server that is not managed by Patroni to archive/restore WALs from the `pgBackRest` server, edit the server's main configuration file directly and adjust the `archive_command` and `restore_command` variables as shown above.
524
+
!!! note
525
+
When configuring a PostgreSQL server that is not managed by Patroni to archive/restore WALs from the `pgBackRest` server, edit the server's main configuration file directly and adjust the `archive_command` and `restore_command` variables as shown above.
517
526
518
527
## Create backups
519
528
@@ -532,7 +541,7 @@ Run the following commands on the **backup server**:
532
541
```
533
542
534
543
3. Check backup info
535
-
544
+
536
545
```{.bash data-prompt="$"}
537
546
$ sudo -iu postgres pgbackrest --stanza=cluster_1 info
0 commit comments