cloudnative-pg / cloudnative-pg/plugin-barman-cloud
plugin-barman-cloud does not work with r2 S3 compatible storage.
- Dominant language
- Go
- Stars
- 192
- Forks
- 75
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 18
Description
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/machinery@v0.2.0/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/controller-runtime@v0.20.4/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/client-go@v0.32.3/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/machinery@v0.2.0/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/cobra@v1.9.1/command.go:1015\ngithub.com/spf13/cobra.(*Command).ExecuteC\n\tpkg/mod/github.com/spf13/cobra@v1.9.1/command.go:1148\ngithub.com/spf13/cobra.(*Command).Execute\n\tpkg/mod/github.com/spf13/cobra@v1.9.1/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"}
```
Contributor guide
Research direction
Start with the supplied R2 ObjectStore configuration and Cloudflare's S3 compatibility matrix. Trace the barman-cloud-wal-archive invocation through internal/cmd/manager/instance/restore/restore.go and cmd.go, then reproduce the restore failure and gather the underlying command output. Done means identifying and resolving the R2 restore failure so the supplied configuration can restore successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, postgresql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100