For security reasons, charm credentials are not stored inside backups. So, if you plan to restore to a backup at any point in the future, you will need the operator, replication, and rewind user passwords for your existing cluster.
You can retrieve them with:
juju run postgresql/leader get-password username=operator
juju run postgresql/leader get-password username=replication
juju run postgresql/leader get-password username=rewind
I tried this, but when I ran juju run-action postgresql/leader create-backup --wait I got a message saying Unit cannot perform backups as it is the cluster primary.
Also, it says you can list your “available, failed and in progress backups” with list-backups, but I had a failed backup as follows:
$ juju run-action postgresql/3 create-backup --wait
unit-postgresql-3:
UnitId: postgresql/3
id: "8"
message: Failed to backup PostgreSQL
results: {}
status: failed
timing:
completed: 2023-05-26 14:09:27 +0000 UTC
enqueued: 2023-05-26 14:09:23 +0000 UTC
started: 2023-05-26 14:09:24 +0000 UTC
It is possible to create backup on primary/leader in case of single unit installation.
If you have a cluster (2+ units) the charm will force you to use non-primary unit.
I will improve the documentation to mention this details.
As for Failed to backup PostgreSQL can you please share the debug-log with the error (if any).
You can contact Marcelo directly to trace it in place on your side. Could be something new RadosGW related. Tnx!
The issue was related to a bug in the charm that prevented a backup to be performed in the primary unit (when TLS is not enabled). It was fixed and the revision in the 14/edge channel should work now (for backups requested to the primary unit when TLS is disabled and in the replicas when TLS is enabled).
Is it worth mentioning that an operator also needs to take copies of the operator, replication and rewind user passwords from their existing cluster if they want to restore to another cluster at any point in the future? This certainly took me by surprise and isn’t something we were doing until a member of my team pointed me at the “Prerequisites” section of Charmhub | Deploy Charmed PostgreSQL VM using Charmhub - The Open Operator Collection.
@avgomes please improve this section or create a reference from here to “restore [your] and [foreign] backup” to prevent negative UX in the future. Tnx!