Skip to content

Commit c5ffd28

Browse files
Create from Backup Documentation
This commit adds documentation that describes how a new cluster can now be created using a backup from another cluster. This includes a brief overview of this feature in the 'Common Tasks' section of the PostgreSQL Operator documentation, along with further information inside of the 'Provisioning' section.
1 parent c1f0902 commit c5ffd28

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

docs/content/architecture/provisioning.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,53 @@ For more information on how this works and what configuration settings are
128128
editable, please visit the "[Custom PostgreSQL configuration]({{< relref "/advanced/custom-configuration.md" >}})"
129129
section of the documentation.
130130

131+
## Provisioning Using a Backup from an Another PostgreSQL Cluster
132+
133+
When provisioning a new PostgreSQL cluster, it is possible to bootstrap the cluster using an
134+
existing backup from either another PostgreSQL cluster that is currently running, or from a
135+
PostgreSQL cluster that no longer exists (specifically a cluster that was deleted using the
136+
`keep-backups` option, as discussed in section [Deprovisioning](#deprovisioning) below). This
137+
is specifically accomplished by performing a `pgbackrest restore` during cluster initialization
138+
in order to populate the initial `PGDATA` directory for the new cluster using the contents of a
139+
backup from another cluster.
140+
141+
To leverage this capability, the name of the cluster containing the backup that should be utilzed
142+
when restoring simply needs to be specified using the `restore-from` option when creating a new
143+
cluster:
144+
145+
```shell
146+
pgo create cluster mycluster2 --restore-from=mycluster1
147+
```
148+
149+
By default, pgBackRest will restore the latest backup available in the repository, and will replay
150+
all available WAL archives. However, additional pgBackRest options can be specified using the
151+
`restore-opts` option, which allows the restore command to be further tailored and customized. For
152+
instance, the following demonstrates how a point-in-time restore can be utilized when creating a
153+
new cluster:
154+
155+
```shell
156+
pgo create cluster mycluster2 \
157+
--restore-from=mycluster1 \
158+
--restore-opts="--type=time --target='2020-07-02 20:19:36.13557+00'"
159+
```
160+
161+
Additionally, if bootstrapping from a cluster the utilizes AWS S3 storage with pgBackRest (or a
162+
cluster that utilized AWS S3 storage in the case of a former cluster), you can also also specify
163+
`s3` as the repository type in order to restore from a backup stored in an S3 storage bucket:
164+
165+
```shell
166+
pgo create cluster mycluster2 \
167+
--restore-from=mycluster1 \
168+
--restore-opts="--repo-type=s3"
169+
```
170+
171+
When restoring from a cluster that is currently running, the new cluster will simply connect to
172+
the existing pgBackRest repository host for that cluster in order to perform the pgBackRest
173+
restore. If restoring from a former cluster that has since been deleted, a new pgBackRest
174+
repository host will be deployed for the sole purpose of bootstrapping the new cluster, and will
175+
then be destroyed once the restore is complete. Also, please note that it is only possible for
176+
one cluster to bootstrap from another cluster (whether running or not) at any given time.
177+
131178
## Deprovisioning
132179

133180
There may become a point where you need to completely deprovision, or delete, a

docs/content/pgo-client/common-tasks.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,30 @@ pgo create cluster hactsluster \
348348
--tablespace=name=ts2:storageconfig=gce:pvcsize=20Gi
349349
```
350350

351+
#### Create a PostgreSQL Cluster Using a Backup from Another PostgreSQL Cluster
352+
353+
It is also possible to create a new PostgreSQL Cluster using a backup from another
354+
PostgreSQL cluster. To do so, simply specify the cluster containing the backup
355+
that you would like to utilize using the `restore-from` option:
356+
357+
358+
```shell
359+
pgo create cluster hacluster2 --restore-from=hacluster1
360+
```
361+
362+
When using this approach, a `pgbackrest restore` will be performed using the pgBackRest
363+
repository for the `restore-from` cluster specified in order to populate the initial
364+
`PGDATA` directory for the new PostgreSQL cluster. By default, pgBackRest will restore
365+
to the latest backup available and replay all WAL. However, a `restore-opts` option
366+
is also available that allows the `restore` command to be further customized, e.g. to
367+
perform a point-in-time restore and/or restore from an S3 storage bucket:
368+
369+
```shell
370+
pgo create cluster hacluster2 \
371+
--restore-from=hacluster1 \
372+
--restore-opts="--repo-type=s3 --type=time --target='2020-07-02 20:19:36.13557+00'"
373+
```
374+
351375
#### Tracking a Newly Provisioned Cluster
352376

353377
A new PostgreSQL cluster can take a few moments to provision. You may have

0 commit comments

Comments
 (0)