diff --git a/charts/cluster/README.md b/charts/cluster/README.md index b3d37062ad..efaf842368 100644 --- a/charts/cluster/README.md +++ b/charts/cluster/README.md @@ -188,6 +188,7 @@ Kubernetes: `>=1.29.0-0` | backups.scheduledBackups[0].name | string | `"daily-backup"` | Scheduled backup name | | backups.scheduledBackups[0].pluginConfiguration | object | `{}` | | | backups.scheduledBackups[0].schedule | string | `"0 0 0 * * *"` | Schedule in cron format | +| backups.scheduledBackups[0].target | string | `""` | The policy to decide which instance should perform this backup, one of `primary` or `prefer-standby`. If empty, it defaults to `cluster.spec.backup.target`. | | backups.secret.create | bool | `true` | Whether to create a secret for the backup credentials | | backups.secret.name | string | `""` | Name of the backup credentials secret | | backups.wal.compression | string | `"gzip"` | WAL compression method. One of `` (for no compression), `gzip`, `bzip2` or `snappy`. | diff --git a/charts/cluster/templates/scheduled-backups.yaml b/charts/cluster/templates/scheduled-backups.yaml index 985a464822..b092247f7c 100644 --- a/charts/cluster/templates/scheduled-backups.yaml +++ b/charts/cluster/templates/scheduled-backups.yaml @@ -15,6 +15,9 @@ spec: schedule: {{ .schedule | quote }} method: {{ .method }} backupOwnerReference: {{ .backupOwnerReference }} + {{- with .target }} + target: {{ . }} + {{- end }} cluster: name: {{ include "cluster.fullname" $ }} {{- with .pluginConfiguration }} diff --git a/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster-assert.yaml b/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster-assert.yaml index cac56a54ac..b0b56dcb6e 100644 --- a/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster-assert.yaml +++ b/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster-assert.yaml @@ -34,6 +34,7 @@ spec: schedule: "0 0 0 * * *" method: plugin backupOwnerReference: self + target: prefer-standby cluster: name: scheduledbackups-cluster --- @@ -46,6 +47,7 @@ spec: schedule: "0 0 0 * * 1" method: plugin backupOwnerReference: self + target: primary cluster: name: scheduledbackups-cluster pluginConfiguration: diff --git a/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster.yaml b/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster.yaml index bc89a5898d..5d663702db 100644 --- a/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster.yaml +++ b/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster.yaml @@ -37,11 +37,13 @@ backups: schedule: "0 0 0 * * *" backupOwnerReference: self method: plugin + target: prefer-standby pluginConfiguration: name: barman-cloud.cloudnative-pg.io - name: weekly-backup schedule: "0 0 0 * * 1" backupOwnerReference: self method: plugin + target: primary pluginConfiguration: name: barman-cloud.cloudnative-pg.io diff --git a/charts/cluster/values.schema.json b/charts/cluster/values.schema.json index cf581a8577..46219ffc7f 100644 --- a/charts/cluster/values.schema.json +++ b/charts/cluster/values.schema.json @@ -206,6 +206,11 @@ "default": "0 0 0 * * *", "description": "Schedule in cron format", "type": "string" + }, + "target": { + "default": "", + "description": "The policy to decide which instance should perform this backup, one of `primary` or `prefer-standby`. If empty, it defaults to `cluster.spec.backup.target`.", + "type": "string" } }, "required": [], diff --git a/charts/cluster/values.yaml b/charts/cluster/values.yaml index a85aa39f9b..3c8d6a53d1 100644 --- a/charts/cluster/values.yaml +++ b/charts/cluster/values.yaml @@ -568,6 +568,8 @@ backups: schedule: "0 0 0 * * *" # -- Backup owner reference backupOwnerReference: self + # -- The policy to decide which instance should perform this backup, one of `primary` or `prefer-standby`. If empty, it defaults to `cluster.spec.backup.target`. + target: "" # -- Backup method, can be `barmanObjectStore` (default), `volumeSnapshot` or `plugin`. method: barmanObjectStore pluginConfiguration: {}