# Pbm backup failed command listCollections requires authentication

**URL:** <https://forums.percona.com/t/pbm-backup-failed-command-listcollections-requires-authentication/25766>\
**Category:** Percona Backup for MongoDB\
**Created:** [October 9, 2023, 8:16am UTC](https://forums.percona.com/t/pbm-backup-failed-command-listcollections-requires-authentication/25766 "2023-10-09T08:16:56Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Max\_Chen](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/max_chen/32/10212_2.png) [@Max\_Chen](https://forums.percona.com/u/Max_Chen)\
**Post date:** [October 9, 2023, 8:16am UTC](https://forums.percona.com/t/pbm-backup-failed-command-listcollections-requires-authentication/25766/1 "2023-10-09T08:16:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Dmytro\_Zghoba](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/dmytro_zghoba/32/4721_2.png) [@Dmytro\_Zghoba](https://forums.percona.com/u/Dmytro_Zghoba)\
**Post date:** [October 9, 2023, 8:44am UTC](https://forums.percona.com/t/pbm-backup-failed-command-listcollections-requires-authentication/25766/2 "2023-10-09T08:44:20Z")

</div>

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](https://docs.percona.com/percona-backup-mongodb/install/initial-setup.html#configure-authentication-in-mongodb)

---

<div class="post-metadata">

**Author:** ![Max\_Chen](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/max_chen/32/10212_2.png) [@Max\_Chen](https://forums.percona.com/u/Max_Chen)\
**Post date:** [October 9, 2023, 8:54am UTC](https://forums.percona.com/t/pbm-backup-failed-command-listcollections-requires-authentication/25766/3 "2023-10-09T08:54:02Z")

</div>

Hi @Dmytro_Zghoba , still the same error after following the operation

1. Create the role that allows any action on any resource.

```auto
db.getSiblingDB("admin").createRole({ "role": "pbmAnyAction",
      "privileges": [
         { "resource": { "anyResource": true },
           "actions": ["anyAction"]
         }
      ],
      "roles": []
   });

```

1. Create the user and assign the role you created to it.

```auto
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

---

<div class="post-metadata">

**Author:** ![Dmytro\_Zghoba](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/dmytro_zghoba/32/4721_2.png) [@Dmytro\_Zghoba](https://forums.percona.com/u/Dmytro_Zghoba)\
**Post date:** [October 9, 2023, 9:35am UTC](https://forums.percona.com/t/pbm-backup-failed-command-listcollections-requires-authentication/25766/4 "2023-10-09T09:35:31Z")

</div>

Can you describe your cluster?

---

<div class="post-metadata">

**Author:** ![Dmytro\_Zghoba](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/dmytro_zghoba/32/4721_2.png) [@Dmytro\_Zghoba](https://forums.percona.com/u/Dmytro_Zghoba)\
**Post date:** [October 9, 2023, 9:36am UTC](https://forums.percona.com/t/pbm-backup-failed-command-listcollections-requires-authentication/25766/5 "2023-10-09T09:36:11Z")

</div>

Is it shareded? PSMDB or CE/EE? version? which node fails configsvr or shardsvr?

---

<div class="post-metadata">

**Author:** ![Dmytro\_Zghoba](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/dmytro_zghoba/32/4721_2.png) [@Dmytro\_Zghoba](https://forums.percona.com/u/Dmytro_Zghoba)\
**Post date:** [October 9, 2023, 9:37am UTC](https://forums.percona.com/t/pbm-backup-failed-command-listcollections-requires-authentication/25766/6 "2023-10-09T09:37:17Z")

</div>

What type of backup? Full or Selective logical?

---

<div class="post-metadata">

**Author:** ![Max\_Chen](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/max_chen/32/10212_2.png) [@Max\_Chen](https://forums.percona.com/u/Max_Chen)\
**Post date:** [October 9, 2023, 9:40am UTC](https://forums.percona.com/t/pbm-backup-failed-command-listcollections-requires-authentication/25766/7 "2023-10-09T09:40:35Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![Max\_Chen](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/max_chen/32/10212_2.png) [@Max\_Chen](https://forums.percona.com/u/Max_Chen)\
**Post date:** [October 10, 2023, 5:07am UTC](https://forums.percona.com/t/pbm-backup-failed-command-listcollections-requires-authentication/25766/8 "2023-10-10T05:07:06Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![Parag\_Bhayani](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/parag_bhayani/32/3710_2.png) [@Parag\_Bhayani](https://forums.percona.com/u/Parag_Bhayani)\
**Post date:** [October 11, 2023, 1:43pm UTC](https://forums.percona.com/t/pbm-backup-failed-command-listcollections-requires-authentication/25766/9 "2023-10-11T13:43:46Z")

</div>

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
