plugin-barman-cloud does not work with r2 S3 compatible storage.
Hello,
I've had an issue with using plugin-barman-cloud with r2 provider from Cloudflare. Whilst the backups seem to create propertly, it seems not possible to restore.
I assume that this is an r2 issue, as the logs reference an rpc exception, but I am happy to do more to debug this if people can help me with additional steps. I attach the R2 compatibility matrix for S3 below:
https://developers.cloudflare.com/r2/api/s3/api/
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: y-psql
namespace: default
spec:
instances: 1
imageName: ghcr.io/cloudnative-pg/postgis:16
bootstrap:
recovery:
source: clusterBackup
plugins:
- name: barman-cloud.cloudnative-pg.io
parameters:
barmanObjectName: r2-store
externalClusters:
- name: clusterBackup
plugin:
name: barman-cloud.cloudnative-pg.io
parameters:
barmanObjectName: r2-store-live
serverName: y-psql
monitoring:
enablePodMonitor: true
storage:
pvcTemplate:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
---
apiVersion: barmancloud.cnpg.io/v1
kind: ObjectStore
metadata:
name: r2-store
spec:
configuration:
destinationPath: "s3://pg-backup/dev-y-psql"
endpointURL: "https://uniqueid.r2.cloudflarestorage.com"
s3Credentials:
accessKeyId:
name: r2
key: AccessKey
secretAccessKey:
name: r2
key: SecretKey
wal:
compression: gzip
Defaulted container "full-recovery" out of: full-recovery, bootstrap-controller (init), plugin-barman-cloud (init)
{"level":"info","ts":"2025-06-20T12:31:12.738563178Z","msg":"Starting webserver","logging_pod":"y-psql-1-full-recovery","address":"localhost:8010","hasTLS":false}
{"level":"info","ts":"2025-06-20T12:31:12.839569885Z","msg":"Restore through plugin detected, proceeding...","logging_pod":"y-psql-1-full-recovery"}
{"level":"error","ts":"2025-06-20T12:31:15.194986191Z","msg":"Error while restoring a backup","logging_pod":"y-psql-1-full-recovery","error":"rpc error: code = Unknown desc = unexpected failure invoking barman-cloud-wal-archive: exit status 1","stacktrace":"github.com/cloudnative-pg/machinery/pkg/log.(*logger).Error\n\tpkg/mod/github.com/cloudnative-pg/[email protected]/pkg/log/log.go:125\ngithub.com/cloudnative-pg/cloudnative-pg/internal/cmd/manager/instance/restore.restoreSubCommand\n\tinternal/cmd/manager/instance/restore/restore.go:79\ngithub.com/cloudnative-pg/cloudnative-pg/internal/cmd/manager/instance/restore.(*restoreRunnable).Start\n\tinternal/cmd/manager/instance/restore/restore.go:62\nsigs.k8s.io/controller-runtime/pkg/manager.(*runnableGroup).reconcile.func1\n\tpkg/mod/sigs.k8s.io/[email protected]/pkg/manager/runnable_group.go:226"}
{"level":"info","ts":"2025-06-20T12:31:15.19525982Z","msg":"Stopping and waiting for non leader election runnables"}
{"level":"info","ts":"2025-06-20T12:31:15.195285188Z","msg":"Stopping and waiting for leader election runnables"}
{"level":"info","ts":"2025-06-20T12:31:15.195420772Z","msg":"Webserver exited","logging_pod":"y-psql-1-full-recovery","address":"localhost:8010"}
{"level":"info","ts":"2025-06-20T12:31:15.195433711Z","msg":"Stopping and waiting for caches"}
{"level":"info","ts":"2025-06-20T12:31:15.195665953Z","msg":"pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:251: watch of *v1.Cluster ended with: an error on the server (\"unable to decode an event from the watch stream: context canceled\") has prevented the request from succeeding"}
{"level":"info","ts":"2025-06-20T12:31:15.195859656Z","msg":"Stopping and waiting for webhooks"}
{"level":"info","ts":"2025-06-20T12:31:15.195880376Z","msg":"Stopping and waiting for HTTP servers"}
{"level":"info","ts":"2025-06-20T12:31:15.196018661Z","msg":"Wait completed, proceeding to shutdown the manager"}
{"level":"error","ts":"2025-06-20T12:31:15.196045833Z","msg":"restore error","logging_pod":"y-psql-1-full-recovery","error":"while restoring cluster: rpc error: code = Unknown desc = unexpected failure invoking barman-cloud-wal-archive: exit status 1","stacktrace":"github.com/cloudnative-pg/machinery/pkg/log.(*logger).Error\n\tpkg/mod/github.com/cloudnative-pg/[email protected]/pkg/log/log.go:125\ngithub.com/cloudnative-pg/cloudnative-pg/internal/cmd/manager/instance/restore.NewCmd.func1\n\tinternal/cmd/manager/instance/restore/cmd.go:101\ngithub.com/spf13/cobra.(*Command).execute\n\tpkg/mod/github.com/spf13/[email protected]/command.go:1015\ngithub.com/spf13/cobra.(*Command).ExecuteC\n\tpkg/mod/github.com/spf13/[email protected]/command.go:1148\ngithub.com/spf13/cobra.(*Command).Execute\n\tpkg/mod/github.com/spf13/[email protected]/command.go:1071\nmain.main\n\tcmd/manager/main.go:71\nruntime.main\n\t/opt/hostedtoolcache/go/1.24.3/x64/src/runtime/proc.go:283"}
Could you please check if the workaround for boto compatibility described here resolves your issue? https://cloudnative-pg.io/plugin-barman-cloud/docs/next/object_stores/#s3-compatible-storage-providers
I am having the same issue but with Storj as storage provider. @mnencia the workaround for boto did not work for me
I am having the same issue but with Storj as storage provider. @mnencia the workaround for boto did not work for me
This is unexpected, it should work accordingly to their documentation:
https://storj.dev/dcs/api/s3/s3-compatibility#compatibility-with-python-sdk-and-cli
I think its a problem with the plugin or with the manifest configuration (mine worked fine before switching to the plugin)
---
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: cluster
namespace: cnpg-database
spec:
instances: 2
storage:
size: 10Gi
bootstrap:
recovery:
source: clusterBackup
plugins:
- name: barman-cloud.cloudnative-pg.io
isWALArchiver: true
parameters:
barmanObjectName: storj-store
externalClusters:
- name: clusterBackup
plugin:
name: barman-cloud.cloudnative-pg.io
parameters:
barmanObjectName: storj-store
serverName: cluster
---
apiVersion: barmancloud.cnpg.io/v1
kind: ObjectStore
metadata:
name: storj-store
namespace: cnpg-database
spec:
instanceSidecarConfiguration:
env:
- name: AWS_REQUEST_CHECKSUM_CALCULATION
value: when_required
- name: AWS_RESPONSE_CHECKSUM_VALIDATION
value: when_required
configuration:
destinationPath: s3://cloudnativepg-backup/
endpointURL: https://gateway.storjshare.io
s3Credentials:
accessKeyId:
name: storj
key: STORJ_ACCESS_KEY_ID
secretAccessKey:
name: storj
key: STORJ_SECRET_ACCESS_KEY
data:
compression: bzip2
wal:
compression: bzip2
maxParallel: 8
I have the same Problem, even when configuring the workardound with AWS_REQUEST_CHECKSUM_CALCULATION and AWS_RESPONSE_CHECKSUM_VALIDATION backups are working but retention policies dont work.
I also tried the 0.4.1 Version of the sidecar container image, which uses an older barman version and it works with that version
I have the same Problem, even when configuring the workardound with AWS_REQUEST_CHECKSUM_CALCULATION and AWS_RESPONSE_CHECKSUM_VALIDATION backups are working but retention policies dont work.
I do have the same issue but with Dell ECS - retention jobs are failing due to missing Content-MD5 header:
{
"level":"error",
"ts":"2025-08-18T13:31:31.528057879Z",
"logger":"barman",
"msg":"Error invoking barman-cloud-backup-delete",
"logging_pod":"database-1",
"options":["--endpoint-url","https://x.y.z","--cloud-provider","aws-s3","--retention-policy","RECOVERY WINDOW OF 7 DAYS","s3://xyz/backups/cnpg/xyz/","database"],
"stdout":"",
"stderr":"2025-08-18 13:31:31,448 [93] ERROR: Could not delete backup 20250605T172947: An error occurred (InvalidRequest) when calling the DeleteObjects operation: Missing required header for this request: Content-MD5\n",
"error":"exit status 1",
"stacktrace":"github.com/cloudnative-pg/machinery/pkg/log.(*logger).Error\n\t/go/pkg/mod/github.com/cloudnative-pg/[email protected]/pkg/log/log.go:125\ngithub.com/cloudnative-pg/barman-cloud/pkg/command.DeleteBackupsByPolicy\n\t/go/pkg/mod/github.com/cloudnative-pg/[email protected]/pkg/command/backupdelete.go:71\ngithub.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/instance.(*CatalogMaintenanceRunnable).maintenance\n\t/workspace/internal/cnpgi/instance/retention.go:131\ngithub.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/instance.(*CatalogMaintenanceRunnable).cycle\n\t/workspace/internal/cnpgi/instance/retention.go:80\ngithub.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/instance.(*CatalogMaintenanceRunnable).Start\n\t/workspace/internal/cnpgi/instance/retention.go:48\nsigs.k8s.io/controller-runtime/pkg/manager.(*runnableGroup).reconcile.func1\n\t/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/manager/runnable_group.go:226"
}
{
"level":"error",
"ts":"2025-08-18T13:59:07.68786648Z",
"msg":"while enforcing retention policies",
"logging_pod":"database-1",
"error":"exit status 1","
stacktrace":"github.com/cloudnative-pg/machinery/pkg/log.(*logger).Error\n\t/go/pkg/mod/github.com/cloudnative-pg/[email protected]/pkg/log/log.go:125\ngithub.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/instance.(*CatalogMaintenanceRunnable).maintenance\n\t/workspace/internal/cnpgi/instance/retention.go:138\ngithub.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/instance.(*CatalogMaintenanceRunnable).cycle\n\t/workspace/internal/cnpgi/instance/retention.go:80\ngithub.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/instance.(*CatalogMaintenanceRunnable).Start\n\t/workspace/internal/cnpgi/instance/retention.go:48\nsigs.k8s.io/controller-runtime/pkg/manager.(*runnableGroup).reconcile.func1\n\t/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/manager/runnable_group.go:226"
}
{
"level":"error",
"ts":"2025-08-18T13:59:07.687932887Z",
"msg":"Retention policy enforcement failed",
"logging_pod":"database-1",
"error":"exit status 1",
"stacktrace":"github.com/cloudnative-pg/machinery/pkg/log.(*logger).Error\n\t/go/pkg/mod/github.com/cloudnative-pg/[email protected]/pkg/log/log.go:125\ngithub.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/instance.(*CatalogMaintenanceRunnable).Start\n\t/workspace/internal/cnpgi/instance/retention.go:50\nsigs.k8s.io/controller-runtime/pkg/manager.(*runnableGroup).reconcile.func1\n\t/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/manager/runnable_group.go:226"
}
Would it be possible to provide image flavor with barman==3.13.3 for these old object storages?
@rofafor you can go with the latest barman version, but you could change the boto3 version to use a version <1.36 in the docker image which is compatible for your s3 compatible storage.
f.e. create a dockerfile with the following content:
FROM ghcr.io/cloudnative-pg/plugin-barman-cloud-sidecar:v0.5.0
USER root
RUN set -xe; \
pip install --upgrade pip && \
pip install boto3==1.35.99
Sure, forking your own image is always a possibility and it works hopefully as long as barman/boto3 doesn't change their interface, but it would be really nice to have ready made image for these old standard object storages and automatic upstream test runs to validate the basic functionality.
Edit: I downgraded first barman to an older version and noticed that backup.info files aren't compatible and one needs to drop encryption field from them, so eventually boto3 downgrade is the way to go. Now, as these images are distroless, you just can use simple RUN statement, but need a bit of multi-stage magic.
# Based on https://github.com/cloudnative-pg/plugin-barman-cloud/blob/v0.6.0/containers/Dockerfile.sidecar
FROM ghcr.io/cloudnative-pg/plugin-barman-cloud-sidecar:v0.6.0 AS gomanager
# Use plugin-barman-cloud-base to get the dependencies.
# pip will build everything inside /usr, so we copy every file into a new
# destination that will then be copied into the distroless container
FROM ghcr.io/cloudnative-pg/plugin-barman-cloud-base:3.14.1-202508210758 AS pythonbuilder
# Downgrade boto3 for Dell ECS support
RUN pip install --root-user-action=ignore boto3==1.35.99
RUN mkdir /new-usr/ && \
cp -r --parents /usr/local/lib/ /usr/lib/*-linux-gnu/ /usr/local/bin/ \
/new-usr/
# Joint process
# Now we put everything that was build from the origin into our
# distroless container
FROM gcr.io/distroless/python3-debian12:nonroot
ENV SUMMARY="CloudNativePG Barman plugin" \
DESCRIPTION="Container image that provides the barman-cloud sidecar" \
AWS_REQUEST_CHECKSUM_CALCULATION=when_required \
AWS_RESPONSE_CHECKSUM_VALIDATION=when_required
LABEL summary="$SUMMARY" \
description="$DESCRIPTION" \
io.k8s.display-name="$SUMMARY" \
io.k8s.description="$DESCRIPTION" \
name="CloudNativePG Barman plugin sidecar" \
vendor="CloudNativePG Contributors" \
url="https://cloudnative-pg.io/" \
version="" \
release="1"
COPY --from=pythonbuilder /new-usr/* /usr/
COPY --from=gomanager /manager /manager
USER 26:26
ENTRYPOINT ["/manager"]
I do have similar issues with StorageGrid and Dell ECS, the two object stores available in my enterprise. And I'm not keen toogenerate / maintain myself the sidecar image with a lower version of boto due to internal challenges in an air-gapped environment
Could the project team consider a suitable solution ?
{
"level": "info",
"ts": "2025-08-31T07:43:55.023859491Z",
"msg": "Applying backup retention policy",
"logging_pod": "pg17-lp-ecs-1",
"retentionPolicy": "1d"
}
{
"level": "error",
"ts": "2025-08-31T07:45:58.903326134Z",
"logger": "barman",
"msg": "Error invoking barman-cloud-backup-delete",
"logging_pod": "pg17-lp-ecs-1",
"options": [
"--endpoint-url",
http: //ecs-storage-uk.it.xxx.xxx:9020,
"--cloud-provider",
"aws-s3",
"--retention-policy",
"RECOVERY WINDOW OF 1 DAYS",
"s3://uk_dukpg00484_03_non-production",
"pg17-lp-ecs"
],
"stdout": "",
"stderr": "2025-08-31 07:45:58,847 [2637] ERROR: Could not delete backup 20250829T172758: An error occurred (InvalidRequest) when calling the DeleteObjects operation: Missing required header for this request: Content-MD5\n",
"error": "exit status 1",
"stacktrace": "github.com/cloudnative-pg/machinery/pkg/log.(*logger).Error\n\t/go/pkg/mod/github.com/cloudnative-pg/[email protected]/pkg/log/log.go:125\ngithub.com/cloudnative-pg/barman-cloud/pkg/command.DeleteBackupsByPolicy\n\t/go/pkg/mod/github.com/cloudnative-pg/[email protected]/pkg/command/backupdelete.go:71\ngithub.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/instance.(*CatalogMaintenanceRunnable).maintenance\n\t/workspace/internal/cnpgi/instance/retention.go:128\ngithub.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/instance.(*CatalogMaintenanceRunnable).cycle\n\t/workspace/internal/cnpgi/instance/retention.go:77\ngithub.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/instance.(*CatalogMaintenanceRunnable).Start\n\t/workspace/internal/cnpgi/instance/retention.go:45\nsigs.k8s.io/controller-runtime/pkg/manager.(*runnableGroup).reconcile.func1\n\t/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/manager/runnable_group.go:226"
}
{
"level": "error",
"ts": "2025-08-31T07:45:58.903734366Z",
"msg": "while enforcing retention policies",
"logging_pod": "pg17-lp-ecs-1",
"error": "exit status 1",
"stacktrace": "github.com/cloudnative-pg/machinery/pkg/log.(*logger).Error\n\t/go/pkg/mod/github.com/cloudnative-pg/[email protected]/pkg/log/log.go:125\ngithub.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/instance.(*CatalogMaintenanceRunnable).maintenance\n\t/workspace/internal/cnpgi/instance/retention.go:135\ngithub.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/instance.(*CatalogMaintenanceRunnable).cycle\n\t/workspace/internal/cnpgi/instance/retention.go:77\ngithub.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/instance.(*CatalogMaintenanceRunnable).Start\n\t/workspace/internal/cnpgi/instance/retention.go:45\nsigs.k8s.io/controller-runtime/pkg/manager.(*runnableGroup).reconcile.func1\n\t/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/manager/runnable_group.go:226"
}
{
"level": "error",
"ts": "2025-08-31T07:45:58.903777576Z",
"msg": "Retention policy enforcement failed",
"logging_pod": "pg17-lp-ecs-1",
"error": "exit status 1",
"stacktrace": "github.com/cloudnative-pg/machinery/pkg/log.(*logger).Error\n\t/go/pkg/mod/github.com/cloudnative-pg/[email protected]/pkg/log/log.go:125\ngithub.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/instance.(*CatalogMaintenanceRunnable).Start\n\t/workspace/internal/cnpgi/instance/retention.go:47\nsigs.k8s.io/controller-runtime/pkg/manager.(*runnableGroup).reconcile.func1\n\t/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/manager/runnable_group.go:226"
}
We do have the same issue here with an NetApp StorageGrid. We've made a custom sidecar image but same as vadius, we would like to avoid creating a pipeline to workaround this issue.
I have the same problem with the retention policies not working because the MD5 header is missing. However I have seen that a fix has been included in Barman v3.16. When will the plugin-barman-cloud include the new Barman version? At the moment this issue is kind of blocking for us.
I’m seeing a similar failure when the plugin enforces retention.
barman-cloud-backup-delete fails with:
An error occurred (BadDigest) when calling the DeleteObjects operation.
The Content-MD5 you specified did not match what we received.
This happens during a Multi-Object Delete (DeleteObjects). Uploads/backups succeed; only the delete call fails. Appears to be an S3-compatibility / Content-MD5 mismatch on multi-delete.
Barman Version 3.16.2 is out and should fix this issue now
Am happy to report that the issue about retention policy is fixed in my environment with the cloud plugin 0.9.0 / barman 3.16.2 and Dell ECS. And I feel the same issue was resolved with 0.8.0 and StorageGrid although it was not my primary focus
Retention policy enforcement still fails with plugin 0.9.0 here
Didn't had time to check with 0.9.0 but 0.8.0 was still failing.
This is now fixed for me. My problem was I was trying to restore from a cluster named the same as the server I backed up from (well, I deleted my original server to test the backup, then tried to restore the cluster with the same name), because of this I have an error in restore because the WAL archive directory was not empty.
To fix, I renamed backup directory to "y-psql-restorefrom" then told the plugin that was the server name to restore from.
- Feature Request: https://github.com/cloudnative-pg/cloudnative-pg/issues/5203
- skipEmptyWalArchiveCheck is a possible solution, but have not tested. Seems dangerous....
Other problems on this thread may be unrelated.... (No Content-MD5 errors on my setup)