diff --git a/config/crd/bases/postgres-operator.crunchydata.com_postgresclusters.yaml b/config/crd/bases/postgres-operator.crunchydata.com_postgresclusters.yaml
index 2f5a807ea5..34af71b557 100644
--- a/config/crd/bases/postgres-operator.crunchydata.com_postgresclusters.yaml
+++ b/config/crd/bases/postgres-operator.crunchydata.com_postgresclusters.yaml
@@ -43,6 +43,12 @@ spec:
pgbackrest:
description: pgBackRest archive configuration
properties:
+ command:
+ description: The command for pgBackRest containers. The default
+ is "/opt/crunchy/bin/pgbackrest".
+ items:
+ type: string
+ type: array
configuration:
description: 'Projected volumes containing custom pgBackRest
configuration. These files are mounted under "/etc/pgbackrest/conf.d"
diff --git a/docs/content/references/crd.md b/docs/content/references/crd.md
index da9487e063..4d6074cf15 100644
--- a/docs/content/references/crd.md
+++ b/docs/content/references/crd.md
@@ -1811,6 +1811,11 @@ pgBackRest archive configuration
[]object |
Defines a pgBackRest repository |
true |
+
+ command |
+ []string |
+ The command for pgBackRest containers. The default is "/opt/crunchy/bin/pgbackrest". |
+ false |
configuration |
[]object |
diff --git a/internal/controller/postgrescluster/pgbackrest.go b/internal/controller/postgrescluster/pgbackrest.go
index 0dfdbb52e7..68958714c1 100644
--- a/internal/controller/postgrescluster/pgbackrest.go
+++ b/internal/controller/postgrescluster/pgbackrest.go
@@ -679,7 +679,6 @@ func generateBackupJobSpecIntent(postgresCluster *v1beta1.PostgresCluster,
cmdOpts = append(cmdOpts, opts...)
container := corev1.Container{
- Command: []string{"/opt/crunchy/bin/pgbackrest"},
Env: []corev1.EnvVar{
{Name: "COMMAND", Value: "backup"},
{Name: "COMMAND_OPTS", Value: strings.Join(cmdOpts, " ")},
@@ -694,6 +693,12 @@ func generateBackupJobSpecIntent(postgresCluster *v1beta1.PostgresCluster,
SecurityContext: initialize.RestrictedSecurityContext(),
}
+ if postgresCluster.Spec.Backups.PGBackRest.Command != nil {
+ container.Command = postgresCluster.Spec.Backups.PGBackRest.Command
+ } else {
+ container.Command = []string{"/opt/crunchy/bin/pgbackrest"}
+ }
+
if postgresCluster.Spec.Backups.PGBackRest.Jobs != nil {
container.Resources = postgresCluster.Spec.Backups.PGBackRest.Jobs.Resources
}
diff --git a/internal/controller/postgrescluster/pgbackrest_test.go b/internal/controller/postgrescluster/pgbackrest_test.go
index fc456990a3..f4ad8cf34c 100644
--- a/internal/controller/postgrescluster/pgbackrest_test.go
+++ b/internal/controller/postgrescluster/pgbackrest_test.go
@@ -2715,6 +2715,19 @@ volumes:
}
})
})
+
+ t.Run("Command", func(t *testing.T) {
+ cmd := []string{"cmd", "blah"}
+ cluster := &v1beta1.PostgresCluster{}
+ cluster.Spec.Backups.PGBackRest.Command = cmd
+ job, err := generateBackupJobSpecIntent(
+ cluster, v1beta1.PGBackRestRepo{},
+ "",
+ nil, nil,
+ )
+ assert.NilError(t, err)
+ assert.DeepEqual(t, job.Template.Spec.Containers[0].Command, cmd)
+ })
}
func TestGenerateRepoHostIntent(t *testing.T) {
diff --git a/pkg/apis/postgres-operator.crunchydata.com/v1beta1/pgbackrest_types.go b/pkg/apis/postgres-operator.crunchydata.com/v1beta1/pgbackrest_types.go
index 4826c72a12..883d3d4e61 100644
--- a/pkg/apis/postgres-operator.crunchydata.com/v1beta1/pgbackrest_types.go
+++ b/pkg/apis/postgres-operator.crunchydata.com/v1beta1/pgbackrest_types.go
@@ -120,6 +120,10 @@ type PGBackRestArchive struct {
// +optional
Image string `json:"image,omitempty"`
+ // The command for pgBackRest containers. The default is "/opt/crunchy/bin/pgbackrest".
+ // +optional
+ Command []string `json:"command,omitempty"`
+
// Jobs field allows configuration for all backup jobs
// +optional
Jobs *BackupJobs `json:"jobs,omitempty"`
diff --git a/pkg/apis/postgres-operator.crunchydata.com/v1beta1/zz_generated.deepcopy.go b/pkg/apis/postgres-operator.crunchydata.com/v1beta1/zz_generated.deepcopy.go
index 95de20538d..5d4f813654 100644
--- a/pkg/apis/postgres-operator.crunchydata.com/v1beta1/zz_generated.deepcopy.go
+++ b/pkg/apis/postgres-operator.crunchydata.com/v1beta1/zz_generated.deepcopy.go
@@ -405,6 +405,11 @@ func (in *PGBackRestArchive) DeepCopyInto(out *PGBackRestArchive) {
(*out)[key] = val
}
}
+ if in.Command != nil {
+ in, out := &in.Command, &out.Command
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
if in.Jobs != nil {
in, out := &in.Jobs, &out.Jobs
*out = new(BackupJobs)