-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathindex.html
More file actions
718 lines (692 loc) · 31.7 KB
/
index.html
File metadata and controls
718 lines (692 loc) · 31.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="author" content="The CloudNativePG Contributors" />
<link rel="shortcut icon" href="../../img/favicon.ico" />
<title>Appendix B - Backup on object stores - CloudNativePG v1.26</title>
<link rel="stylesheet" href="../../css/theme.css" />
<link rel="stylesheet" href="../../css/theme_extra.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/github.min.css" />
<link href="../../css/override.css" rel="stylesheet" />
<script>
// Current page data
var mkdocs_page_name = "Appendix B - Backup on object stores";
var mkdocs_page_input_path = "appendixes/backup_barmanobjectstore.md";
var mkdocs_page_url = null;
</script>
<!--[if lt IE 9]>
<script src="../../js/html5shiv.min.js"></script>
<![endif]-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
<script>hljs.highlightAll();</script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="../.." class="icon icon-home"> CloudNativePG v1.26
</a><div role="search">
<form id ="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" title="Type search term here" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../..">CloudNativePG</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../before_you_start/">Before you start</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../use_cases/">Use cases</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">Architecture</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../installation_upgrade/">Installation and upgrades</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../quickstart/">Quickstart</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../image_catalog/">Image Catalog</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../bootstrap/">Bootstrap</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../database_import/">Importing Postgres databases</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../instance_manager/">Postgres Instance Manager</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../scheduling/">Scheduling</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../resource_management/">Resource management</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../failure_modes/">Failure Modes</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../rolling_update/">Rolling updates</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../replication/">Replication</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../logical_replication/">Logical Replication</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../backup/">Backup</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../wal_archiving/">WAL archiving</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../recovery/">Recovery</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../service_management/">Service management</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../postgresql_conf/">PostgreSQL Configuration</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../declarative_role_management/">PostgreSQL Role management</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../declarative_database_management/">PostgreSQL Database management</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../tablespaces/">Tablespaces</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../operator_conf/">Operator configuration</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../cluster_conf/">Instance Pod configuration</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../storage/">Storage</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../labels_annotations/">Labels and Annotations</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../monitoring/">Monitoring</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../logging/">Logging</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../certificates/">Certificates</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../ssl_connections/">Client TLS/SSL connections</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../applications/">Connecting from an application</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../connection_pooling/">Connection Pooling</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../replica_cluster/">Replica clusters</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../kubernetes_upgrade/">Kubernetes upgrade and maintenance</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../postgres_upgrades/">PostgreSQL upgrades</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../kubectl-plugin/">Kubectl Plugin</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../failover/">Automated failover</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../troubleshooting/">Troubleshooting</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../fencing/">Fencing</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../declarative_hibernation/">Declarative hibernation</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../postgis/">PostGIS</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../e2e/">End-to-End Tests</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../container_images/">Container Image Requirements</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../cnpg_i/">CNPG-I</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../operator_capability_levels/">Operator capability levels</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../controller/">Custom Pod Controller</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../samples/">Examples</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../networking/">Networking</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../benchmarking/">Benchmarking</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../faq/">Frequently Asked Questions (FAQ)</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../cloudnative-pg.v1/">API Reference</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../supported_releases/">Supported releases</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../preview_version/">Preview Versions</a>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../release_notes/">Release notes</a>
</li>
</ul>
<p class="caption"><span class="caption-text">CNCF Projects Integrations</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../cncf-projects/external-secrets/">External Secrets</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../cncf-projects/cilium/">Cilium</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Appendixes</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../backup_volumesnapshot/">Appendix A - Backup on volume snapshots</a>
</li>
<li class="toctree-l1 current"><a class="reference internal current" href="#">Appendix B - Backup on object stores</a>
<ul class="current">
<li class="toctree-l2"><a class="reference internal" href="#common-object-stores">Common object stores</a>
</li>
<li class="toctree-l2"><a class="reference internal" href="#wal-archiving">WAL archiving</a>
</li>
<li class="toctree-l2"><a class="reference internal" href="#retention-policies">Retention policies</a>
</li>
<li class="toctree-l2"><a class="reference internal" href="#compression-algorithms">Compression algorithms</a>
</li>
<li class="toctree-l2"><a class="reference internal" href="#tagging-of-backup-objects">Tagging of backup objects</a>
</li>
<li class="toctree-l2"><a class="reference internal" href="#extra-options-for-the-backup-and-wal-commands">Extra options for the backup and WAL commands</a>
</li>
<li class="toctree-l2"><a class="reference internal" href="#recovery-from-an-object-store">Recovery from an object store</a>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../object_stores/">Appendix C - Common object stores for backups</a>
</li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="Mobile navigation menu">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../..">CloudNativePG v1.26</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content"><div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../.." class="icon icon-home" aria-label="Docs"></a></li>
<li class="breadcrumb-item">Appendixes</li>
<li class="breadcrumb-item active">Appendix B - Backup on object stores</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div class="section" itemprop="articleBody">
<h1 id="appendix-b-backup-on-object-stores">Appendix B - Backup on object stores</h1>
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>As of CloudNativePG 1.26, <strong>native Barman Cloud support is deprecated</strong> in
favor of the <strong>Barman Cloud Plugin</strong>. This page has been moved to the appendix
for reference purposes. While the native integration remains functional for
now, we strongly recommend beginning a gradual migration to the plugin-based
interface after appropriate testing. For guidance, see
<a href="https://cloudnative-pg.io/plugin-barman-cloud/docs/migration/">Migrating from Built-in CloudNativePG Backup</a>.</p>
</div>
<p>CloudNativePG natively supports <strong>online/hot backup</strong> of PostgreSQL
clusters through continuous physical backup and WAL archiving on an object
store. This means that the database is always up (no downtime required)
and that Point In Time Recovery is available.</p>
<p>The operator can orchestrate a continuous backup infrastructure
that is based on the <a href="https://pgbarman.org">Barman Cloud</a> tool. Instead
of using the classical architecture with a Barman server, which
backs up many PostgreSQL instances, the operator relies on the
<code>barman-cloud-wal-archive</code>, <code>barman-cloud-check-wal-archive</code>,
<code>barman-cloud-backup</code>, <code>barman-cloud-backup-list</code>, and
<code>barman-cloud-backup-delete</code> tools. As a result, base backups will
be <em>tarballs</em>. Both base backups and WAL files can be compressed
and encrypted.</p>
<p>For this, it is required to use an image with <code>barman-cli-cloud</code> included.
You can use the image <code>ghcr.io/cloudnative-pg/postgresql</code> for this scope,
as it is composed of a community PostgreSQL image and the latest
<code>barman-cli-cloud</code> package.</p>
<div class="admonition important">
<p class="admonition-title">Important</p>
<p>Always ensure that you are running the latest version of the operands
in your system to take advantage of the improvements introduced in
Barman cloud (as well as improve the security aspects of your cluster).</p>
</div>
<div class="admonition warning">
<p class="admonition-title">Changes in Barman Cloud 3.16+ and Bucket Creation</p>
<p>Starting with Barman Cloud 3.16, most Barman Cloud commands no longer
automatically create the target bucket, assuming it already exists. Only the
<code>barman-cloud-check-wal-archive</code> command creates the bucket now. Whenever this
is not the first operation run on an empty bucket, CloudNativePG will throw an
error. As a result, to ensure reliable, future-proof operations and avoid
potential issues, we strongly recommend that you create and configure your
object store bucket <em>before</em> creating a <code>Cluster</code> resource that references it.</p>
</div>
<p>A backup is performed from a primary or a designated primary instance in a
<code>Cluster</code> (please refer to
<a href="../../replica_cluster/">replica clusters</a>
for more information about designated primary instances), or alternatively
on a <a href="../../backup/#backup-from-a-standby">standby</a>.</p>
<h2 id="common-object-stores">Common object stores</h2>
<p>If you are looking for a specific object store such as
<a href="../object_stores/#aws-s3">AWS S3</a>,
<a href="../object_stores/#azure-blob-storage">Microsoft Azure Blob Storage</a>,
<a href="../object_stores/#google-cloud-storage">Google Cloud Storage</a>, or a compatible
provider, please refer to <a href="../object_stores/">Appendix C - Common object stores for backups</a>.</p>
<h2 id="wal-archiving">WAL archiving</h2>
<p>WAL archiving is the process that feeds a <a href="../../backup/#wal-archive">WAL archive</a>
in CloudNativePG.</p>
<p>The WAL archive is defined in the <code>.spec.backup.barmanObjectStore</code> stanza of
a <code>Cluster</code> resource.</p>
<div class="admonition info">
<p class="admonition-title">Info</p>
<p>Please refer to <a href="https://pkg.go.dev/github.com/cloudnative-pg/barman-cloud/pkg/api#BarmanObjectStoreConfiguration"><code>BarmanObjectStoreConfiguration</code></a>
in the barman-cloud API for a full list of options.</p>
</div>
<p>If required, you can choose to compress WAL files as soon as they
are uploaded and/or encrypt them:</p>
<pre><code class="language-yaml">apiVersion: postgresql.cnpg.io/v1
kind: Cluster
[...]
spec:
backup:
barmanObjectStore:
[...]
wal:
compression: gzip
encryption: AES256
</code></pre>
<p>You can configure the encryption directly in your bucket, and the operator
will use it unless you override it in the cluster configuration.</p>
<p>PostgreSQL implements a sequential archiving scheme, where the
<code>archive_command</code> will be executed sequentially for every WAL
segment to be archived.</p>
<div class="admonition important">
<p class="admonition-title">Important</p>
<p>By default, CloudNativePG sets <code>archive_timeout</code> to <code>5min</code>, ensuring
that WAL files, even in case of low workloads, are closed and archived
at least every 5 minutes, providing a deterministic time-based value for
your Recovery Point Objective (<a href="../../before_you_start/#rpo">RPO</a>). Even though you change the value
of the <a href="https://www.postgresql.org/docs/current/runtime-config-wal.html#GUC-ARCHIVE-TIMEOUT"><code>archive_timeout</code> setting in the PostgreSQL configuration</a>,
our experience suggests that the default value set by the operator is
suitable for most use cases.</p>
</div>
<p>When the bandwidth between the PostgreSQL instance and the object
store allows archiving more than one WAL file in parallel, you
can use the parallel WAL archiving feature of the instance manager
like in the following example:</p>
<pre><code class="language-yaml">apiVersion: postgresql.cnpg.io/v1
kind: Cluster
[...]
spec:
backup:
barmanObjectStore:
[...]
wal:
compression: gzip
maxParallel: 8
encryption: AES256
</code></pre>
<p>In the previous example, the instance manager optimizes the WAL
archiving process by archiving in parallel at most eight ready
WALs, including the one requested by PostgreSQL.</p>
<p>When PostgreSQL will request the archiving of a WAL that has
already been archived by the instance manager as an optimization,
that archival request will be just dismissed with a positive status.</p>
<h2 id="retention-policies">Retention policies</h2>
<p>CloudNativePG can manage the automated deletion of backup files from
the backup object store, using <strong>retention policies</strong> based on the recovery
window.</p>
<p>Internally, the retention policy feature uses <code>barman-cloud-backup-delete</code>
with <code>--retention-policy “RECOVERY WINDOW OF {{ retention policy value }} {{ retention policy unit }}”</code>.</p>
<p>For example, you can define your backups with a retention policy of 30 days as
follows:</p>
<pre><code class="language-yaml">apiVersion: postgresql.cnpg.io/v1
kind: Cluster
[...]
spec:
backup:
barmanObjectStore:
destinationPath: "<destination path here>"
s3Credentials:
accessKeyId:
name: aws-creds
key: ACCESS_KEY_ID
secretAccessKey:
name: aws-creds
key: ACCESS_SECRET_KEY
retentionPolicy: "30d"
</code></pre>
<div class="admonition note">
<p class="admonition-title">There's more ...</p>
<p>The <strong>recovery window retention policy</strong> is focused on the concept of
<em>Point of Recoverability</em> (<code>PoR</code>), a moving point in time determined by
<code>current time - recovery window</code>. The <em>first valid backup</em> is the first
available backup before <code>PoR</code> (in reverse chronological order).
CloudNativePG must ensure that we can recover the cluster at
any point in time between <code>PoR</code> and the latest successfully archived WAL
file, starting from the first valid backup. Base backups that are older
than the first valid backup will be marked as <em>obsolete</em> and permanently
removed after the next backup is completed.</p>
</div>
<h2 id="compression-algorithms">Compression algorithms</h2>
<p>CloudNativePG by default archives backups and WAL files in an
uncompressed fashion. However, it also supports the following compression
algorithms via <code>barman-cloud-backup</code> (for backups) and
<code>barman-cloud-wal-archive</code> (for WAL files):</p>
<ul>
<li>bzip2</li>
<li>gzip</li>
<li>lz4</li>
<li>snappy</li>
<li>xz</li>
<li>zstd</li>
</ul>
<p>The compression settings for backups and WALs are independent. See the
<a href="https://pkg.go.dev/github.com/cloudnative-pg/barman-cloud/pkg/api#DataBackupConfiguration">DataBackupConfiguration</a> and
<a href="https://pkg.go.dev/github.com/cloudnative-pg/barman-cloud/pkg/api#WalBackupConfiguration">WALBackupConfiguration</a> sections in
the barman-cloud API reference.</p>
<p>It is important to note that archival time, restore time, and size change
between the algorithms, so the compression algorithm should be chosen according
to your use case.</p>
<p>The Barman team has performed an evaluation of the performance of the supported
algorithms for Barman Cloud. The following table summarizes a scenario where a
backup is taken on a local MinIO deployment. The Barman GitHub project includes
a <a href="https://github.com/EnterpriseDB/barman/issues/344#issuecomment-992547396">deeper analysis</a>.</p>
<table>
<thead>
<tr>
<th>Compression</th>
<th>Backup Time (ms)</th>
<th>Restore Time (ms)</th>
<th>Uncompressed size (MB)</th>
<th>Compressed size (MB)</th>
<th>Approx ratio</th>
</tr>
</thead>
<tbody>
<tr>
<td>None</td>
<td>10927</td>
<td>7553</td>
<td>395</td>
<td>395</td>
<td>1:1</td>
</tr>
<tr>
<td>bzip2</td>
<td>25404</td>
<td>13886</td>
<td>395</td>
<td>67</td>
<td>5.9:1</td>
</tr>
<tr>
<td>gzip</td>
<td>116281</td>
<td>3077</td>
<td>395</td>
<td>91</td>
<td>4.3:1</td>
</tr>
<tr>
<td>snappy</td>
<td>8134</td>
<td>8341</td>
<td>395</td>
<td>166</td>
<td>2.4:1</td>
</tr>
</tbody>
</table>
<h2 id="tagging-of-backup-objects">Tagging of backup objects</h2>
<p>Barman 2.18 introduces support for tagging backup resources when saving them in
object stores via <code>barman-cloud-backup</code> and <code>barman-cloud-wal-archive</code>. As a
result, if your PostgreSQL container image includes Barman with version 2.18 or
higher, CloudNativePG enables you to specify tags as key-value pairs
for backup objects, namely base backups, WAL files and history files.</p>
<p>You can use two properties in the <code>.spec.backup.barmanObjectStore</code> definition:</p>
<ul>
<li><code>tags</code>: key-value pair tags to be added to backup objects and archived WAL
file in the backup object store</li>
<li><code>historyTags</code>: key-value pair tags to be added to archived history files in
the backup object store</li>
</ul>
<p>The excerpt of a YAML manifest below provides an example of usage of this
feature:</p>
<pre><code class="language-yaml">apiVersion: postgresql.cnpg.io/v1
kind: Cluster
[...]
spec:
backup:
barmanObjectStore:
[...]
tags:
backupRetentionPolicy: "expire"
historyTags:
backupRetentionPolicy: "keep"
</code></pre>
<h2 id="extra-options-for-the-backup-and-wal-commands">Extra options for the backup and WAL commands</h2>
<p>You can append additional options to the <code>barman-cloud-backup</code> and <code>barman-cloud-wal-archive</code> commands by using
the <code>additionalCommandArgs</code> property in the
<code>.spec.backup.barmanObjectStore.data</code> and <code>.spec.backup.barmanObjectStore.wal</code> sections respectively.
These properties are lists of strings that will be appended to the
<code>barman-cloud-backup</code> and <code>barman-cloud-wal-archive</code> commands.</p>
<p>For example, you can use the <code>--read-timeout=60</code> to customize the connection
reading timeout.</p>
<p>For additional options supported by <code>barman-cloud-backup</code> and <code>barman-cloud-wal-archive</code> commands you can refer to the
official barman documentation <a href="https://www.pgbarman.org/documentation/">here</a>.</p>
<p>If an option provided in <code>additionalCommandArgs</code> is already present in the
declared options in its section (<code>.spec.backup.barmanObjectStore.data</code> or <code>.spec.backup.barmanObjectStore.wal</code>), the extra option will be
ignored.</p>
<p>The following is an example of how to use this property:</p>
<p>For backups:</p>
<pre><code class="language-yaml">apiVersion: postgresql.cnpg.io/v1
kind: Cluster
[...]
spec:
backup:
barmanObjectStore:
[...]
data:
additionalCommandArgs:
- "--min-chunk-size=5MB"
- "--read-timeout=60"
</code></pre>
<p>For WAL files:</p>
<pre><code class="language-yaml">apiVersion: postgresql.cnpg.io/v1
kind: Cluster
[...]
spec:
backup:
barmanObjectStore:
[...]
wal:
additionalCommandArgs:
- "--max-concurrency=1"
- "--read-timeout=60"
</code></pre>
<h2 id="recovery-from-an-object-store">Recovery from an object store</h2>
<p>You can recover from a backup created by Barman Cloud and stored on a supported
object store. After you define the external cluster, including all the required
configuration in the <code>barmanObjectStore</code> section, you need to reference it in
the <code>.spec.recovery.source</code> option.</p>
<p>This example defines a recovery object store in a blob container in Azure:</p>
<pre><code class="language-yaml">apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: cluster-restore
spec:
[...]
superuserSecret:
name: superuser-secret
bootstrap:
recovery:
source: clusterBackup
externalClusters:
- name: clusterBackup
barmanObjectStore:
destinationPath: https://STORAGEACCOUNTNAME.blob.core.windows.net/CONTAINERNAME/
azureCredentials:
storageAccount:
name: recovery-object-store-secret
key: storage_account_name
storageKey:
name: recovery-object-store-secret
key: storage_account_key
wal:
maxParallel: 8
</code></pre>
<p>The previous example assumes that the application database and its owning user
are named <code>app</code> by default. If the PostgreSQL cluster being restored uses
different names, you must specify these names before exiting the recovery phase,
as documented in <a href="../../recovery/#configure-the-application-database">"Configure the application database"</a>.</p>
<div class="admonition important">
<p class="admonition-title">Important</p>
<p>By default, the <code>recovery</code> method strictly uses the <code>name</code> of the
cluster in the <code>externalClusters</code> section as the name of the main folder
of the backup data within the object store. This name is normally reserved
for the name of the server. You can specify a different folder name
using the <code>barmanObjectStore.serverName</code> property.</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>This example takes advantage of the parallel WAL restore feature,
dedicating up to 8 jobs to concurrently fetch the required WAL files from the
archive. This feature can appreciably reduce the recovery time. Make sure that
you plan ahead for this scenario and correctly tune the value of this parameter
for your environment. It will make a difference when you need it, and you will.</p>
</div>
</div>
</div><footer>
<div class="rst-footer-buttons" role="navigation" aria-label="Footer Navigation">
<a href="../backup_volumesnapshot/" class="btn btn-neutral float-left" title="Appendix A - Backup on volume snapshots"><span class="icon icon-circle-arrow-left"></span> Previous</a>
<a href="../object_stores/" class="btn btn-neutral float-right" title="Appendix C - Common object stores for backups">Next <span class="icon icon-circle-arrow-right"></span></a>
</div>
<hr/>
<div role="contentinfo">
<!-- Copyright etc -->
<p>Copyright © CloudNativePG a Series of LF Projects, LLC</p>
</div>
Built with <a href="https://www.mkdocs.org/">MkDocs</a> using a <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<div class="rst-versions" role="note" aria-label="Versions">
<span class="rst-current-version" data-toggle="rst-current-version">
<span><a href="../backup_volumesnapshot/" style="color: #fcfcfc">« Previous</a></span>
<span><a href="../object_stores/" style="color: #fcfcfc">Next »</a></span>
</span>
</div>
<script src="../../js/jquery-3.6.0.min.js"></script>
<script>var base_url = "../..";</script>
<script src="../../js/theme_extra.js"></script>
<script src="../../js/theme.js"></script>
<script src="../../search/main.js"></script>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>