Skip to content

Backup to different object store #611

Open

Description

@flx5

Hi,
first of all thank you for the amazing work!

I might have a bit of an odd use case:
Currently I have two S3 compatible object stores. One onsite and one for offsite backups. Because the connection to the offsite one can be quite slow (this is a homelab setup), I didn't want to send WALs to the offsite S3 but just baseline backups every so often.

From what I can tell the BackupServiceImplementation currently just uses the barmanObjectKey from the cluster definition and ignores any parameters specified directly on the Backup or BackupSchedule CRD.

Would it be possible to support overriding the object store in the backup crd like this?

apiVersion: postgresql.cnpg.io/v1
kind: Backup
metadata:
  name: backup-example
spec:
  cluster:
    name: pg-nextcloud
  method: plugin
  pluginConfiguration:
    name: barman-cloud.cloudnative-pg.io
    parameters:
      barmanObjectName: anotherObjectStore
  

Activity

  1. dosubot commented on Oct 19, 2025

    @dosubot

    Hi @flx5! I'm Dosu and I’m helping the plugin-barman-cloud team.

    You're correct—right now, CloudNativePG and the barman-cloud plugin do not support overriding the object store per backup using parameters in the Backup CRD. The object store is always selected based on the cluster-level configuration, specifically the barmanObjectName set in the Cluster's plugin section. Any parameters like barmanObjectName in the Backup or ScheduledBackup CRD are ignored by the backup execution logic, so per-backup object store selection isn't possible at this time [docs].

    If you need to send only base backups to your offsite store, the only workaround is to temporarily change the cluster's plugin configuration to point to the offsite object store before triggering a backup, then switch it back for regular operations. This approach has risks (like potential WAL archiving disruption during the switch), so use with caution.

    There are no existing discussions or issues about supporting this feature, but your use case is valid and could be a good candidate for a future enhancement.

    To reply, just mention @dosu.


    Share context across your team and agents. Try Dosu.

    Leave Feedback Learn about plugin-barman-cloud with Dosu Add Dosu to your team

  2. dragoangel commented on Oct 19, 2025

    @dragoangel

    @flx5 I also want to extend this part if you not mind - retentionPolicy of "another" barman CR should be also honored. What for me is an issue: barman from what I read in recovery window docs - stores both full WAL & backups up to retentionPolicy time.

    So if I need 30 days of backups, I have to choose one of:

    1. create custom sync jobs that would "copy" my daily backups to another storage for older time and manage their expiration on my own
    2. delete WAL archives for days I not interested in manually from S3

    Both variants sounds like wrong things to do, idealy it should be possible via:

    1. isWALArchiver enabled just on current primary cluster, now it ignored AFAIK
    2. retentionPolicy defined in barmanObjectName which writes WAL is set window I want to get PITR from, f.e.: 2d or 7d
    3. scheduledBackup runs daily and refers another barmanObjectName which has own retentionPolicy which is to to window for which I expect have "daily full backups" in place, f.e.: 30d
    4. scheduledBackup runs monthly and refers another barmanObjectName which has own retentionPolicy for which I expect have "montly full backups" in palce, f.e.: 1y
  3. ildar-fix commented on Aug 26, 2026

    @ildar-fix

    We ran into this as well, and it is still the behaviour on main (v0.14.0+12): BackupServiceImplementation.Backup
    builds its configuration with config.NewFromClusterJSON(request.ClusterDefinition) and never looks at
    request.Parameters, although the operator does relay Backup.spec.pluginConfiguration.parameters in the
    BackupRequest (pkg/management/postgres/webserver/plugin_backup.go -> internal/cnpi/plugin/client/backup.go).
    The backup ends up completed with no warning, so the only symptom is an archive that stays empty.

    We have a fix running on a test stand (CNPG 1.30.0, S3): a Backup carrying
    parameters.barmanObjectName: archive-store lands in that store, WALs keep going to the cluster store, and a
    cluster bootstrapped from that pair comes up with all the data.

    Before sending a PR we would like your opinion on two points.

    1. RBAC. Honouring the parameter is not enough on its own. The Role bound to the instance service account is
    built from the object stores the Cluster refers to (rbac.EnsureRole <- GetReferredBarmanObjectsKey), so a
    Backup naming any other store fails with
    objectstores.barmancloud.cnpg.io "archive-store" is forbidden. We solved it with a cluster level plugin
    parameter, additionalBarmanObjectNames: a comma separated list of stores that take part in the RBAC and in the
    certificates of the instances, while nothing is routed to them. It is declarative and explicit, but it does add
    API surface. If you would rather widen the Role some other way, we are happy to follow that instead.

    2. Scope. Would you take the fix on its own, or do you want per backup object store selection designed more
    broadly, together with @dragoangel's point about the retention of the second store? Separately, and not part of
    this proposal, we also have a working implementation of keeping base backups and WALs in two different object
    stores (a baseBackupBarmanObjectName parameter and the matching recovery path). That is what brought us here:
    our provider sets the storage class per bucket, and base backups and WALs have opposite optimal classes. We can
    open a separate issue for it if there is any appetite.

    The branch is ready against main, with unit tests in the existing Ginkgo suite. We will send it as soon as you
    tell us which shape you prefer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions