Skip to content

Commit f6c1f49

Browse files
committed
K8SPSMDB-1386 Improved restore doc
Added a subsection explaining restores with prefixes define for a bucket
1 parent dea9876 commit f6c1f49

File tree

1 file changed

+53
-19
lines changed

1 file changed

+53
-19
lines changed

docs/backups-restore.md

Lines changed: 53 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,40 @@
11
# Restore the cluster from a previously saved backup
22

3-
The backup is normally restored on the Kubernetes cluster where it was made, but [restoring it on a different Kubernetes-based environment with the installed Operator is also possible](backups-restore-to-new-cluster.md).
3+
This document describes how to restore from a backup on the same the Kubernetes cluster where it was made.
44

5-
Following things are needed to restore a previously saved backup:
5+
You can also [restore a backup on a different Kubernetes-based environment with the installed Operator](backups-restore-to-new-cluster.md) as part of the disaster recovery strategy or when you configure [multi-cluster deployment with cross-site replication](replication.md).
6+
7+
## Restore types
8+
9+
You can make the following restores:
10+
11+
* [Restore to a specific point in time](#make-a-point-in-time-recovery). A precondition for this restore is to [enable saving oplog operations](backups-pitr.md)
12+
* [Restore only a backup snapshot](#restore-without-point-in-time-recovery)
13+
* [Selective restore from a logical backup](#selective-restore)
14+
15+
For either type of a restore you need to create a Restore object using the [`deploy/backup/restore.yaml` :octicons-link-external-16:](<https://github.com/percona/percona-server-mongodb-operator/blob/main/deploy/backup/restore.yaml> manifest.
16+
17+
## Before you begin
618

719
* Make sure that the cluster is running.
8-
* Find out correct names for the **backup** and the **cluster**. Available backups can be listed with the following command:
20+
* Get backup information. List the backups using this command:
921

1022
``` {.bash data-prompt="$" }
1123
$ kubectl get psmdb-backup
1224
```
1325

14-
And the following command will list available clusters:
26+
* Get cluster information. Run the following command to list available clusters:
1527

1628
``` {.bash data-prompt="$" }
1729
$ kubectl get psmdb
1830
```
1931

20-
!!! note
32+
## Restore without point-in-time recovery
2133

22-
If you have [configured storing operations logs for point-in-time recovery](backups-pitr.md), you will have possibility to roll back the cluster to a specific date and time. Otherwise, restoring backups without point-in-time recovery is the only option.
34+
1. Modify the [deploy/backup/restore.yaml :octicons-link-external-16:](https://github.com/percona/percona-server-mongodb-operator/blob/main/deploy/backup/restore.yaml) manifest and set the following keys:
2335

24-
When the correct names for the backup and the cluster are known, backup restoration can be done in the following way.
25-
26-
## Without point-in-time recovery
27-
28-
1. Set appropriate keys in the [deploy/backup/restore.yaml :octicons-link-external-16:](https://github.com/percona/percona-server-mongodb-operator/blob/main/deploy/backup/restore.yaml) file.
29-
30-
* set `spec.clusterName` key to the name of the target cluster to restore the backup on,
31-
* set `spec.backupName` key to the name of your backup,
36+
* set `spec.clusterName` key to the name of the target cluster to restore the backup on. Since you restore on the same cluster where the backup was taken, the cluster name matches.
37+
* set `spec.backupName` key to the name of your backup.
3238

3339
```yaml
3440
apiVersion: psmdb.percona.com/v1
@@ -40,15 +46,15 @@ When the correct names for the backup and the cluster are known, backup restorat
4046
backupName: backup1
4147
```
4248

43-
2. After that, the actual restoration process can be started as follows:
49+
2. Start the restore by creating the Restore object. Use the following command:
4450

4551
``` {.bash data-prompt="$" }
4652
$ kubectl apply -f deploy/backup/restore.yaml
4753
```
4854

4955
!!! note
5056

51-
Storing backup settings in a separate file can be replaced by passing its content to the `kubectl apply` command as follows:
57+
Instead of storing restore settings in a separate file, you can pass them directly to the `kubectl apply` command as follows:
5258

5359
```bash
5460
$ cat <<EOF | kubectl apply -f-
@@ -62,13 +68,13 @@ When the correct names for the backup and the cluster are known, backup restorat
6268
EOF
6369
```
6470
65-
## With point-in-time recovery
71+
## Make a point-in-time recovery
6672
6773
1. Set appropriate keys in the [deploy/backup/restore.yaml :octicons-link-external-16:](https://github.com/percona/percona-server-mongodb-operator/blob/main/deploy/backup/restore.yaml) file.
6874
6975
* set `spec.clusterName` key to the name of the target cluster to restore the backup on
7076
* set `spec.backupName` key to the name of your backup
71-
* put additional restoration parameters to the `pitr` section:
77+
* configure point-in-time recovery settings in the `pitr` section:
7278
* `type` key can be equal to one of the following options
7379
* `date` - roll back to specific date
7480
* `latest` - recover to the latest possible transaction
@@ -125,6 +131,8 @@ When the correct names for the backup and the cluster are known, backup restorat
125131
126132
Starting with the version 1.18.0, you can restore a desired subset of data from a full logical backup. Selective logical backups are not yet supported.
127133
134+
Selective restores have a number of limitations. Learn more about the [current selective restore limitations :octicons-link-external-16:](https://docs.percona.com/percona-backup-mongodb/features/known-limitations.html#selective-backups-and-restores) in Percona Backup for MongoDB documentation.
135+
128136
Selective restores are controlled by the additional `selective` section in the `PerconaServerMongoDBRestore` Custom Resource. There you can specify a specific database or a collection that you wish to restore:
129137
130138
```yaml
@@ -140,5 +148,31 @@ The `selective.namespaces` field allows you to specify several "namespaces" (sub
140148
141149
Also, you can use `selective.withUsersAndRoles` set to `true` to restore a custom database with users and roles from a full backup.
142150
143-
Selective restores support only logical backups and have a number of other limitations. See the full list of [current selective restore limitations :octicons-link-external-16:](https://docs.percona.com/percona-backup-mongodb/features/known-limitations.html#selective-backups-and-restores) in Percona Backup for MongoDB documentation.
151+
## Restore from a backup with a prefix in a bucket path
152+
153+
If you defined a prefix (a folder) in a bucket where you store backups, you must specify this prefix in the `spec.backupSource` subsection of the restore configuration.
154+
155+
To illustrate, let's say you defined a prefix `my-prefix` for your AWS s3 bucket `my-example-bucket`. You wish to restore a backup`2025-05-19T07:23:46Z`. The pull path to this backup is `"s3://my-example-bucket/my-prefix/2025-05-19T07:23:46Z"`. In this case, your restore configuration looks like this:
144156
157+
```yaml
158+
apiVersion: psmdb.percona.com/v1
159+
kind: PerconaServerMongoDBRestore
160+
metadata:
161+
name: restore1
162+
spec:
163+
clusterName: my-cluster-name
164+
backupSource:
165+
type: logical
166+
destination: "s3://my-example-bucket/my-prefix/2025-05-19T07:23:46Z"
167+
s3:
168+
credentialsSecret: my-cluster-name-backup-s3
169+
region: us-east-1
170+
bucket: chetan-testing-percona
171+
prefix: my-prefix
172+
```
173+
174+
Apply this configuration to start a restore:
175+
176+
``` {.bash data-prompt="$" }
177+
$ kubectl apply -f deploy/backup/restore.yaml
178+
```

0 commit comments

Comments
 (0)