Skip to content

Commit 3df62b4

Browse files
authored
K8SPS-591 Improved scheduled backups (#175)
Removed ambiguous wording reg schedule name Improved the wording Added section how to monitor and view scheduled backups
1 parent 3ecc53d commit 3df62b4

File tree

1 file changed

+79
-57
lines changed

1 file changed

+79
-57
lines changed

docs/backups-scheduled.md

Lines changed: 79 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,34 @@
11
# Making scheduled backups
2-
32

4-
Backups schedule is defined in the `backup` section of the Custom
5-
Resource and can be configured via the [deploy/cr.yaml :octicons-link-external-16:](https://github.com/percona/percona-server-mysql-operator/blob/v{{release}}/deploy/cr.yaml)
6-
file.
3+
Scheduled backups run automatically at times you specify. You configure them in the `backup` section of your Custom Resource using the [deploy/cr.yaml :octicons-link-external-16:](https://github.com/percona/percona-server-mysql-operator/blob/v{{release}}/deploy/cr.yaml) file.
74

8-
1. The `backup.storages` subsection should contain at least one [configured storage](backups-storage.md).
5+
Before setting up scheduled backups, make sure you have at least one [configured storage](backups-storage.md) in the `backup.storages` subsection.
96

10-
2. The `backup.schedule` subsection allows to actually schedule backups:
7+
## Configure a backup schedule
118

12-
* set the `backup.schedule.name` key to some arbitrary backup name (this name
13-
will be needed later to [restore the backup](backups-restore.md)).
9+
To schedule backups, specify the following configuration in your Custom Resource:
1410

15-
* specify the `backup.schedule.schedule` option with the desired backup
16-
schedule in [crontab format :octicons-link-external-16:](https://en.wikipedia.org/wiki/Cron).
11+
1. Enable backup by setting `backup.enabled` to `true`.
12+
2. Add entries to the `backup.schedule` subsection in your Custom Resource. Each schedule entry requires the following:
1713

18-
* set the `backup.schedule.storageName` key to the name of your [already configured storage](backups-storage.md).
14+
* `name` - a unique name for this backup schedule
15+
* `schedule` - the backup schedule in [crontab format :octicons-link-external-16:](https://en.wikipedia.org/wiki/Cron). For example, `"0 0 * * 6"` runs every Saturday at midnight.
16+
* `storageName` - the name of your [configured storage](backups-storage.md) where backups will be stored
17+
* `keep` (optional) - the number of backups to keep in storage. Older backups are automatically deleted when this limit is reached.
1918

20-
* you can optionally set the `backup.schedule.keep` key to the number of
21-
backups which should be kept in the storage.
22-
23-
Here is an example of the `deploy/cr.yaml` with a scheduled Saturday night
24-
backup kept on the Amazon S3 storage:
19+
Here's an example configuration that creates a backup every Saturday night at midnight and keeps the last 3 backups:
2520

2621
```yaml
2722
...
2823
backup:
24+
enabled: true
2925
storages:
3026
s3-us-west:
3127
type: s3
3228
s3:
3329
bucket: S3-BACKUP-BUCKET-NAME-HERE
3430
region: us-west-2
35-
credentialsSecret: my-cluster-name-backup-s3
31+
credentialsSecret: ps-cluster1-s3-credentials
3632
schedule:
3733
- name: "sat-night-backup"
3834
schedule: "0 0 * * 6"
@@ -43,56 +39,82 @@ backup:
4339

4440
## Managing multiple backup schedules in the same storage
4541

46-
You can define multiple backup schedules to meet different recovery and compliance needs. For example, create daily backups for quick recovery from recent changes and monthly backups for long-term retention or audit purposes.
47-
48-
When using the same storage location for multiple schedules, be aware of these important considerations:
42+
You can define multiple backup schedules to meet different recovery and compliance needs. For example, you might want daily backups for quick recovery from recent changes and monthly backups for long-term retention or audit purposes.
4943

50-
1. **Retention policy conflicts.** The Operator only applies retention policies to the first schedule in your configuration. For example, if you set daily backups to keep 5 copies and monthly backups to keep 3 copies, the Operator will only keep 5 total backups in storage, not 8 as you might expect. However, all backup objects will still appear in `kubectl get ps-backup` output.
44+
When you use the same storage location for multiple schedules, be aware of these important limitations:
5145

52-
2. **Concurrent backup conflicts.** When multiple schedules run simultaneously and write to the same storage path, backups can overwrite each other, resulting in incomplete or corrupted data.
46+
1. **Retention policy conflicts**: The Operator only applies retention policies to the first schedule in your configuration. For example, if you set daily backups to keep 5 copies and monthly backups to keep 3 copies, the Operator will only keep 5 total backups in storage, not 8 as you might expect. However, all backup objects will still appear in `kubectl get ps-backup` output.
5347

54-
To avoid these issues and ensure each schedule maintains its own retention policy, configure separate storage locations for each schedule.
48+
2. **Concurrent backup conflicts**: When multiple schedules run at the same time and write to the same storage path, backups can overwrite each other, resulting in incomplete or corrupted data.
5549

56-
The configuration steps are the following:
50+
To avoid these issues and ensure each schedule maintains its own retention policy, configure separate storage locations for each schedule. Here's how:
5751

5852
1. Create separate storage configurations in your Custom Resource with different names
5953
2. Specify unique buckets or prefixes for each storage configuration
6054
3. Assign different storage names to specific schedules
6155

62-
Here is the example configuration:
63-
64-
```yaml
65-
storages:
66-
minio1:
67-
type: s3
68-
s3:
69-
credentialsSecret: minio-secret
70-
bucket: my-bucket
71-
prefix: minio1
72-
endpointUrl: "http://minio.minio.svc.cluster.local:9000/"
73-
verifyTLS: false
74-
minio2:
75-
type: s3
76-
s3:
77-
credentialsSecret: minio-secret
78-
bucket: my-bucket
79-
prefix: minio2
80-
endpointUrl: "http://minio.minio.svc.cluster.local:9000/"
81-
verifyTLS: false
82-
83-
....
84-
85-
backup:
86-
schedule:
87-
- name: "daily-backup"
88-
schedule: "0 2 * * *"
89-
keep: 2
90-
storageName: minio1
91-
- name: "monthly-backup"
92-
schedule: "0 2 1 * *"
93-
keep: 5
94-
storageName: minio2
56+
Here's an example configuration that uses separate storage locations for daily and monthly backups:
57+
58+
```yaml
59+
storages:
60+
minio1:
61+
type: s3
62+
s3:
63+
credentialsSecret: minio-secret
64+
bucket: my-bucket
65+
prefix: minio1
66+
endpointUrl: "http://minio.minio.svc.cluster.local:9000/"
67+
verifyTLS: false
68+
minio2:
69+
type: s3
70+
s3:
71+
credentialsSecret: minio-secret
72+
bucket: my-bucket
73+
prefix: minio2
74+
endpointUrl: "http://minio.minio.svc.cluster.local:9000/"
75+
verifyTLS: false
76+
77+
....
78+
79+
backup:
80+
schedule:
81+
- name: "daily-backup"
82+
schedule: "0 2 * * *"
83+
keep: 2
84+
storageName: minio1
85+
- name: "monthly-backup"
86+
schedule: "0 2 1 * *"
87+
keep: 5
88+
storageName: minio2
89+
```
90+
91+
In this example, daily backups are stored in `minio1` and monthly backups are stored in `minio2`, each with their own retention policy.
92+
93+
## Monitoring scheduled backups
94+
95+
When a scheduled backup runs, the Operator creates a Kubernetes Job to execute the backup. You can view these jobs to monitor backup execution:
96+
97+
```bash
98+
kubectl get jobs -n <namespace>
99+
```
100+
101+
??? example "Example output"
102+
103+
```{.text .no-copy}
104+
NAME COMPLETIONS DURATION AGE
105+
xb-cron-ps-cluster2-gcp-20251107152047-9mgo5-gcp 1/1 9s 21s
95106
```
96107

108+
To find all backups created by a specific schedule, use the `percona.com/backup-ancestor` label. The label format is `percona.com/backup-ancestor: <hash>-<schedule-name>`, where `<hash>` is a unique identifier and `<schedule-name>` is the name you specified in your schedule configuration.
97109

110+
For example, to find all backups created by the `sat-night-backup` schedule:
98111

112+
```bash
113+
kubectl get ps-backup -l percona.com/backup-ancestor -n <namespace>
114+
```
115+
116+
Or to filter for a specific schedule:
117+
118+
```bash
119+
kubectl get ps-backup -l percona.com/backup-ancestor=0ed1d-sat-night-backup -n <namespace>
120+
```

0 commit comments

Comments
 (0)