pbm backup --compression=zstd --mongodb-uri xxxxxx
Starting backup ‘2023-10-09T08:10:19Z’…Error: get namespaces size: list collections for “xxx”: (Unauthorized) command listCollections requires authentication
I use the root user and after login can listCollections success but the pbm backup failed. And the xxx changes every time when backup
Anyone know the reason?
pbm version
Version: 2.1.0
Platform: linux/amd64
GitCommit: 342b5b9c996e8bd17a678ea0cecbf2eaaf9704ab
GitBranch: release-2.1.0
BuildTime: 2023-04-14_12:23_UTC
GoVersion: go1.19
Hi @Max_Chen ,
The xxx
is a database name. A PBM user does not have enough permissions to run db.getSiblingDB("the xxx db name").runCommand({ listCollections: 1 })
.
PBM docs: Configure authentication in MongoDB
Hi @Dmytro_Zghoba , still the same error after following the operation
- Create the role that allows any action on any resource.
db.getSiblingDB("admin").createRole({ "role": "pbmAnyAction",
"privileges": [
{ "resource": { "anyResource": true },
"actions": [ "anyAction" ]
}
],
"roles": []
});
- Create the user and assign the role you created to it.
db.getSiblingDB("admin").createUser({user: "pbmuser",
"pwd": "secretpwd",
"roles" : [
{ "db" : "admin", "role" : "readWrite", "collection": "" },
{ "db" : "admin", "role" : "backup" },
{ "db" : "admin", "role" : "clusterMonitor" },
{ "db" : "admin", "role" : "restore" },
{ "db" : "admin", "role" : "pbmAnyAction" }
]
pbm backup --compression=zstd --mongodb-uri mongodb://pbmuser:secretpwd@…/?authSource=admin&replicaSet=rs0
But mongo mongodb://pbmuser:secretpwd@.../?authSource=admin&replicaSet=rs0
db.getSiblingDB(“xxx”).runCommand({ listCollections: 1 });
Can list success
Can you describe your cluster?
Is it shareded? PSMDB or CE/EE? version? which node fails configsvr or shardsvr?
What type of backup? Full or Selective logical?
@Dmytro_Zghoba
Not shard, 3 mongo nodes, 1 primary and 2 secondary.
The Mongo cluster deployed in the k8s cluster uses bitnami Mongo helm chart.
Full backup
After restarting the mongo cluster the backup was successful…
Backup snapshots:
2023-10-10T03:51:04Z [restore_to_time: 2023-10-10T03:51:47Z]
2023-10-10T05:07:54Z [restore_to_time: 2023-10-10T05:08:26Z]
Hi Max,
That is strange but it is great to hear that the backup is working now.
If you face issue again, do let us know.
Regards,
Parag
1 Like