Skip to content

Commit 3c5df07

Browse files
gbartolinifcanovai
andauthored
docs: restructure backup and recovery section for CNPG-I plugins (cloudnative-pg#7581)
With the introduction of the CNPG-I interface and official support for the Barman Cloud Plugin, the backup and recovery documentation has been reorganised to reflect the new plugin-based architecture. This is the first step toward a more modular and extensible approach. Further work is planned outside the core CloudNativePG repository, including maintaining an inventory of available plugins and migrating volume snapshot support into a dedicated plugin. Closes cloudnative-pg#6876 Signed-off-by: Gabriele Bartolini <gabriele.bartolini@enterprisedb.com> Signed-off-by: Francesco Canovai <francesco.canovai@enterprisedb.com> Co-authored-by: Francesco Canovai <francesco.canovai@enterprisedb.com>
1 parent 4970da3 commit 3c5df07

12 files changed

+762
-694
lines changed

.wordlist-en-custom.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ Uncomment
507507
Unrealizable
508508
UpdateStrategy
509509
VLDB
510+
VLDBs
510511
VM
511512
VMs
512513
VOLNAME

docs/mkdocs.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ markdown_extensions:
1414
- def_list
1515
- attr_list
1616
- footnotes
17+
- pymdownx.caret
1718

1819
nav:
1920
- index.md
@@ -34,9 +35,7 @@ nav:
3435
- replication.md
3536
- logical_replication.md
3637
- backup.md
37-
- backup_barmanobjectstore.md
3838
- wal_archiving.md
39-
- backup_volumesnapshot.md
4039
- recovery.md
4140
- service_management.md
4241
- postgresql_conf.md
@@ -77,4 +76,6 @@ nav:
7776
- CNCF Projects Integrations:
7877
- cncf-projects/external-secrets.md
7978
- Appendixes:
79+
- appendixes/backup_volumesnapshot.md
80+
- appendixes/backup_barmanobjectstore.md
8081
- appendixes/object_stores.md

docs/src/backup_barmanobjectstore.md renamed to docs/src/appendixes/backup_barmanobjectstore.md

Lines changed: 143 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
# Backup on object stores
1+
# Appendix B - Backup on object stores
2+
23
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
34

45
!!! Warning
5-
With the deprecation of native Barman Cloud support in CloudNativePG in
6-
favor of the Barman Cloud Plugin, this page—and the backup and recovery
7-
documentation—may undergo changes before the official release of version
8-
1.26.0.
6+
As of CloudNativePG 1.26, **native Barman Cloud support is deprecated** in
7+
favor of the **Barman Cloud Plugin**. This page has been moved to the appendix
8+
for reference purposes. While the native integration remains functional for
9+
now, we strongly recommend beginning a gradual migration to the plugin-based
10+
interface after appropriate testing. For guidance, see
11+
[Migrating from Built-in CloudNativePG Backup](https://cloudnative-pg.io/plugin-barman-cloud/docs/migration/).
912

1013
CloudNativePG natively supports **online/hot backup** of PostgreSQL
1114
clusters through continuous physical backup and WAL archiving on an object
@@ -34,23 +37,90 @@ as it is composed of a community PostgreSQL image and the latest
3437

3538
A backup is performed from a primary or a designated primary instance in a
3639
`Cluster` (please refer to
37-
[replica clusters](replica_cluster.md)
40+
[replica clusters](../replica_cluster.md)
3841
for more information about designated primary instances), or alternatively
39-
on a [standby](backup.md#backup-from-a-standby).
42+
on a [standby](../backup.md#backup-from-a-standby).
4043

4144
## Common object stores
4245

4346
If you are looking for a specific object store such as
44-
[AWS S3](appendixes/object_stores.md#aws-s3),
45-
[Microsoft Azure Blob Storage](appendixes/object_stores.md#azure-blob-storage),
46-
[Google Cloud Storage](appendixes/object_stores.md#google-cloud-storage), or
47-
[MinIO Gateway](appendixes/object_stores.md#minio-gateway), or a compatible
48-
provider, please refer to [Appendix A - Common object stores](appendixes/object_stores.md).
47+
[AWS S3](object_stores.md#aws-s3),
48+
[Microsoft Azure Blob Storage](object_stores.md#azure-blob-storage),
49+
[Google Cloud Storage](object_stores.md#google-cloud-storage), or a compatible
50+
provider, please refer to [Appendix C - Common object stores for backups](object_stores.md).
4951

50-
## Retention policies
52+
## WAL archiving
53+
54+
WAL archiving is the process that feeds a [WAL archive](../backup.md#wal-archive)
55+
in CloudNativePG.
56+
57+
The WAL archive is defined in the `.spec.backup.barmanObjectStore` stanza of
58+
a `Cluster` resource.
59+
60+
!!! Info
61+
Please refer to [`BarmanObjectStoreConfiguration`](https://pkg.go.dev/github.com/cloudnative-pg/barman-cloud/pkg/api#BarmanObjectStoreConfiguration)
62+
in the barman-cloud API for a full list of options.
63+
64+
If required, you can choose to compress WAL files as soon as they
65+
are uploaded and/or encrypt them:
66+
67+
```yaml
68+
apiVersion: postgresql.cnpg.io/v1
69+
kind: Cluster
70+
[...]
71+
spec:
72+
backup:
73+
barmanObjectStore:
74+
[...]
75+
wal:
76+
compression: gzip
77+
encryption: AES256
78+
```
79+
80+
You can configure the encryption directly in your bucket, and the operator
81+
will use it unless you override it in the cluster configuration.
82+
83+
PostgreSQL implements a sequential archiving scheme, where the
84+
`archive_command` will be executed sequentially for every WAL
85+
segment to be archived.
5186

5287
!!! Important
53-
Retention policies are not currently available on volume snapshots.
88+
By default, CloudNativePG sets `archive_timeout` to `5min`, ensuring
89+
that WAL files, even in case of low workloads, are closed and archived
90+
at least every 5 minutes, providing a deterministic time-based value for
91+
your Recovery Point Objective ([RPO](../before_you_start.md#rpo)). Even though you change the value
92+
of the [`archive_timeout` setting in the PostgreSQL configuration](https://www.postgresql.org/docs/current/runtime-config-wal.html#GUC-ARCHIVE-TIMEOUT),
93+
our experience suggests that the default value set by the operator is
94+
suitable for most use cases.
95+
96+
When the bandwidth between the PostgreSQL instance and the object
97+
store allows archiving more than one WAL file in parallel, you
98+
can use the parallel WAL archiving feature of the instance manager
99+
like in the following example:
100+
101+
```yaml
102+
apiVersion: postgresql.cnpg.io/v1
103+
kind: Cluster
104+
[...]
105+
spec:
106+
backup:
107+
barmanObjectStore:
108+
[...]
109+
wal:
110+
compression: gzip
111+
maxParallel: 8
112+
encryption: AES256
113+
```
114+
115+
In the previous example, the instance manager optimizes the WAL
116+
archiving process by archiving in parallel at most eight ready
117+
WALs, including the one requested by PostgreSQL.
118+
119+
When PostgreSQL will request the archiving of a WAL that has
120+
already been archived by the instance manager as an optimization,
121+
that archival request will be just dismissed with a positive status.
122+
123+
## Retention policies
54124

55125
CloudNativePG can manage the automated deletion of backup files from
56126
the backup object store, using **retention policies** based on the recovery
@@ -163,7 +233,7 @@ spec:
163233
You can append additional options to the `barman-cloud-backup` and `barman-cloud-wal-archive` commands by using
164234
the `additionalCommandArgs` property in the
165235
`.spec.backup.barmanObjectStore.data` and `.spec.backup.barmanObjectStore.wal` sections respectively.
166-
This properties are lists of strings that will be appended to the
236+
These properties are lists of strings that will be appended to the
167237
`barman-cloud-backup` and `barman-cloud-wal-archive` commands.
168238

169239
For example, you can use the `--read-timeout=60` to customize the connection
@@ -209,3 +279,61 @@ spec:
209279
- "--max-concurrency=1"
210280
- "--read-timeout=60"
211281
```
282+
283+
## Recovery from an object store
284+
285+
You can recover from a backup created by Barman Cloud and stored on a supported
286+
object store. After you define the external cluster, including all the required
287+
configuration in the `barmanObjectStore` section, you need to reference it in
288+
the `.spec.recovery.source` option.
289+
290+
This example defines a recovery object store in a blob container in Azure:
291+
292+
```yaml
293+
apiVersion: postgresql.cnpg.io/v1
294+
kind: Cluster
295+
metadata:
296+
name: cluster-restore
297+
spec:
298+
[...]
299+
300+
superuserSecret:
301+
name: superuser-secret
302+
303+
bootstrap:
304+
recovery:
305+
source: clusterBackup
306+
307+
externalClusters:
308+
- name: clusterBackup
309+
barmanObjectStore:
310+
destinationPath: https://STORAGEACCOUNTNAME.blob.core.windows.net/CONTAINERNAME/
311+
azureCredentials:
312+
storageAccount:
313+
name: recovery-object-store-secret
314+
key: storage_account_name
315+
storageKey:
316+
name: recovery-object-store-secret
317+
key: storage_account_key
318+
wal:
319+
maxParallel: 8
320+
```
321+
322+
The previous example assumes that the application database and its owning user
323+
are named `app` by default. If the PostgreSQL cluster being restored uses
324+
different names, you must specify these names before exiting the recovery phase,
325+
as documented in ["Configure the application database"](../recovery.md#configure-the-application-database).
326+
327+
!!! Important
328+
By default, the `recovery` method strictly uses the `name` of the
329+
cluster in the `externalClusters` section as the name of the main folder
330+
of the backup data within the object store. This name is normally reserved
331+
for the name of the server. You can specify a different folder name
332+
using the `barmanObjectStore.serverName` property.
333+
334+
!!! Note
335+
This example takes advantage of the parallel WAL restore feature,
336+
dedicating up to 8 jobs to concurrently fetch the required WAL files from the
337+
archive. This feature can appreciably reduce the recovery time. Make sure that
338+
you plan ahead for this scenario and correctly tune the value of this parameter
339+
for your environment. It will make a difference when you need it, and you will.

docs/src/backup_volumesnapshot.md renamed to docs/src/appendixes/backup_volumesnapshot.md

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
# Backup on volume snapshots
1+
# Appendix A - Backup on volume snapshots
22
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
33

4-
!!! Warning
5-
As noted in the [backup document](backup.md), a cold snapshot explicitly
6-
set to target the primary will result in the primary being fenced for
7-
the duration of the backup, rendering the cluster read-only during that
8-
For safety, in a cluster already containing fenced instances, a cold
9-
snapshot is rejected.
4+
!!! Important
5+
Please refer to the official Kubernetes documentation for a list of all
6+
the supported [Container Storage Interface (CSI) drivers](https://kubernetes-csi.github.io/docs/drivers.html)
7+
that provide snapshotting capabilities.
108

119
CloudNativePG is one of the first known cases of database operators that
1210
directly leverages the Kubernetes native Volume Snapshot API for both
@@ -53,18 +51,16 @@ volumes of a given storage class, and managed as `VolumeSnapshot` and
5351
!!! Important
5452
It is your responsibility to verify with the third party vendor
5553
that volume snapshots are supported. CloudNativePG only interacts
56-
with the Kubernetes API on this matter and we cannot support issues
54+
with the Kubernetes API on this matter, and we cannot support issues
5755
at the storage level for each specific CSI driver.
5856

5957
## How to configure Volume Snapshot backups
6058

61-
<!-- TODO: Change before 1.26.0 -->
62-
6359
CloudNativePG allows you to configure a given Postgres cluster for Volume
6460
Snapshot backups through the `backup.volumeSnapshot` stanza.
6561

6662
!!! Info
67-
Please refer to [`VolumeSnapshotConfiguration`](cloudnative-pg.v1.md#postgresql-cnpg-io-v1-VolumeSnapshotConfiguration)
63+
Please refer to [`VolumeSnapshotConfiguration`](../cloudnative-pg.v1.md#postgresql-cnpg-io-v1-VolumeSnapshotConfiguration)
6864
in the API reference for a full list of options.
6965

7066
A generic example with volume snapshots (assuming that PGDATA and WALs share
@@ -89,18 +85,21 @@ spec:
8985
# Volume snapshot backups
9086
volumeSnapshot:
9187
className: @VOLUME_SNAPSHOT_CLASS_NAME@
92-
# WAL archive
93-
barmanObjectStore:
94-
# ...
88+
89+
plugins:
90+
- name: barman-cloud.cloudnative-pg.io
91+
isWALArchiver: true
92+
parameters:
93+
barmanObjectName: @OBJECTSTORE_NAME@
9594
```
9695
9796
As you can see, the `backup` section contains both the `volumeSnapshot` stanza
9897
(controlling physical base backups on volume snapshots) and the
99-
`barmanObjectStore` one (controlling the [WAL archive](wal_archiving.md)).
98+
`plugins` one (controlling the [WAL archive](../wal_archiving.md)).
10099

101100
!!! Info
102-
Once you have defined the `barmanObjectStore`, you can decide to use
103-
both volume snapshot and object store backup strategies simultaneously
101+
Once you have defined the `plugin`, you can decide to use
102+
both volume snapshot and plugin backup strategies simultaneously
104103
to take physical backups.
105104

106105
The `volumeSnapshot.className` option allows you to reference the default
@@ -118,6 +117,13 @@ a `ScheduledBackup` resource that requests such backups on a periodic basis.
118117

119118
## Hot and cold backups
120119

120+
!!! Warning
121+
As noted in the [backup document](../backup.md), a cold snapshot explicitly
122+
set to target the primary will result in the primary being fenced for
123+
the duration of the backup, making the cluster read-only during this
124+
period. For safety, in a cluster already containing fenced instances, a cold
125+
snapshot is rejected.
126+
121127
By default, CloudNativePG requests an online/hot backup on volume snapshots, using the
122128
[PostgreSQL defaults of the low-level API for base backups](https://www.postgresql.org/docs/current/continuous-archiving.html#BACKUP-LOWLEVEL-BASE-BACKUP):
123129

@@ -335,8 +341,6 @@ spec:
335341

336342
## Example of Volume Snapshot Backup
337343

338-
<!-- TODO: Change before 1.26.0 -->
339-
340344
The following example shows how to configure volume snapshot base backups on an
341345
EKS cluster on AWS using the `ebs-sc` storage class and the `csi-aws-vsc`
342346
volume snapshot class.
@@ -349,7 +353,7 @@ volume snapshot class.
349353

350354
The following manifest creates a `Cluster` that is ready to be used for volume
351355
snapshots and that stores the WAL archive in a S3 bucket via IAM role for the
352-
Service Account (IRSA, see [AWS S3](appendixes/object_stores.md#aws-s3)):
356+
Service Account (IRSA, see [AWS S3](object_stores.md#aws-s3)):
353357

354358
``` yaml
355359
apiVersion: postgresql.cnpg.io/v1
@@ -369,13 +373,12 @@ spec:
369373
backup:
370374
volumeSnapshot:
371375
className: csi-aws-vsc
372-
barmanObjectStore:
373-
destinationPath: s3://@BUCKET_NAME@/
374-
s3Credentials:
375-
inheritFromIAMRole: true
376-
wal:
377-
compression: gzip
378-
maxParallel: 2
376+
377+
plugins:
378+
- name: barman-cloud.cloudnative-pg.io
379+
isWALArchiver: true
380+
parameters:
381+
barmanObjectName: @OBJECTSTORE_NAME@
379382
380383
serviceAccountTemplate:
381384
metadata:

0 commit comments

Comments
 (0)