# PBM agent on secondary dumps from primary

**URL:** <https://forums.percona.com/t/pbm-agent-on-secondary-dumps-from-primary/8166>\
**Category:** Percona Backup for MongoDB\
**Created:** [October 22, 2020, 6:39am UTC](https://forums.percona.com/t/pbm-agent-on-secondary-dumps-from-primary/8166 "2020-10-22T06:39:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![juuso](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/juuso/32/1428_2.png) [@juuso](https://forums.percona.com/u/juuso)\
**Post date:** [October 22, 2020, 6:39am UTC](https://forums.percona.com/t/pbm-agent-on-secondary-dumps-from-primary/8166/1 "2020-10-22T06:39:44Z")

</div>

Hi!

We’re trying to set up PBM for a sharded mongo cluster. There’s an agent running on every mongoc and mongod node, and the backup starts just fine. On each shard, the backup gets performed by an agent running on a secondary, but the agent initiates the “mongodump” connection against the shard primary. I’ve confirmed this via `db.currentOp({$all: true})` on the primary. The result is that the uplink of the primary is saturated as data is streamed from there to the secondary, and from there to the configured remote storage. This is something that certainly blocks us from taking the tool into use.

This issue was referred to in [https://jira.percona.com/browse/PBM-407?focusedCommentId=247887&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-247887](https://jira.percona.com/browse/PBM-407?focusedCommentId=247887&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-247887)but I didn’t find any continuation to that particular problem. Am I doing something wrong or is there a bug?

We’re running Mongo 4.2 and PBM 1.3.2. We use TLS with certificate authentication and the PBM\_MONGODB\_URI is of the form:

```auto
mongodb://pbmuser:pass@local.node.fqdn:27017/?tls=true&tlsCertificateKeyFile=/path/to/certkey&tlsCAFile=/path/to/cafile

```

---

<div class="post-metadata">

**Author:** ![Ivan\_Groenewold](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ivan_groenewold/32/6299_2.png) [@Ivan\_Groenewold](https://forums.percona.com/u/Ivan_Groenewold)\
**Post date:** [October 26, 2020, 8:00am UTC](https://forums.percona.com/t/pbm-agent-on-secondary-dumps-from-primary/8166/2 "2020-10-26T08:00:34Z")

</div>

Hi, it is possible there is an incorrect connection string being passed somewhere in the code. Would you mind opening a bug in [jira.percona.com](http://jira.percona.com) so we can get some dev eyes on this?

---

<div class="post-metadata">

**Author:** ![juuso](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/juuso/32/1428_2.png) [@juuso](https://forums.percona.com/u/juuso)\
**Post date:** [October 26, 2020, 9:03am UTC](https://forums.percona.com/t/pbm-agent-on-secondary-dumps-from-primary/8166/3 "2020-10-26T09:03:05Z")

</div>

I added debug logging to right before the MongoDump is initiated, and the connection string is the exact same one as configured. I think the problem is that the connection of the MongoDump isn’t initialized with the “direct” connection option, which leads to the driver autodiscovering the primary and connecting to it instead of the local node. I made a pull request on this: [https://github.com/percona/percona-backup-mongodb/pull/446](https://github.com/percona/percona-backup-mongodb/pull/446) . I’ve tested that it works with our setup. Should I still open a jira issue as well?

---

<div class="post-metadata">

**Author:** ![Ivan\_Groenewold](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ivan_groenewold/32/6299_2.png) [@Ivan\_Groenewold](https://forums.percona.com/u/Ivan_Groenewold)\
**Post date:** [October 26, 2020, 9:13am UTC](https://forums.percona.com/t/pbm-agent-on-secondary-dumps-from-primary/8166/4 "2020-10-26T09:13:39Z")

</div>

Thanks for the PR! I will have somebody check this asap.

---

<div class="post-metadata">

**Author:** ![Akira\_Kurogane](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/akira_kurogane/32/1280_2.png) [@Akira\_Kurogane](https://forums.percona.com/u/Akira_Kurogane)\
**Post date:** [October 27, 2020, 12:48am UTC](https://forums.percona.com/t/pbm-agent-on-secondary-dumps-from-primary/8166/5 "2020-10-27T00:48:30Z")

</div>

Pull request [https://github.com/percona/percona-backup-mongodb/pull/446](https://github.com/percona/percona-backup-mongodb/pull/446) looks good to go.
