Server Selection Error timeout

Im trying to setup Percona backup for Mongodb, and its not as easy as i thought.

The setup is quite simple

1x mongodb docker container
1x percona backup for mongodb container

Mongodb server is running, and is working, started pbm container with: docker run --name percona_backup_master -e PBM_MONGODB_URI=“mongodb://” --network trax_repox_mongo_net -d percona/percona-backup-mongodb:latest’

after 20-30 sec the container exits with the logs entries below:

user@perconatest:/tmp$ docker logs -f percona_backup_master
+ '[' pbm-agent = pbm-agent ']'
++ mktemp
+ OUT=/tmp/tmp.uWEMOOzj6p
++ mktemp
+ OUT_CFG=/tmp/tmp.FwoQ7lhGzc
+ timeout=5
+ for i in {1..10}
+ '[' '' ']'
+ set +o xtrace
+ exit_status=0
++ grep -E '^([0-9]+)$' /tmp/tmp.uWEMOOzj6p
+ rs_size=1
+ [[ 0 == 0 ]]
+ [[ 1 -ge 1 ]]
+ break
+ rm /tmp/tmp.uWEMOOzj6p
+ exec pbm-agent
2023/08/02 08:40:36 Exit: connect to PBM: create mongo connection: mongo ping: server selection error: server selection timeout, current topology: { Type: ReplicaSetNoPrimary, Servers: [{ Addr:, Type: Unknown, Last error: dial tcp connect: connection refused }, ] }

What i dont get, is why its trying to connect to and not the mongodb://

Please help, i´m pretty stuck here, and have to get this working on a sharded cluster, if this POC is working :slight_smile:


Hi Pjotz and welcome to the Percona Community.

It looks like you have a standalone MongoDB instance. PBM does not work against a standalone server, it works only if the Replica Sert is configured.

The thing you can do is restarting the container setting the ReplSetName configuration option and then running rs.initiate() on the node. This way you will get a 1-node Replica Set and sp PBM should work.

Thanks for the reply, will have a look at it tomorrow. and return to you :slight_smile:

Hi @Pjotz ,

For a sharded cluster, run any pbm related commands on Config Server ReplSet since it contains the metadata of the whole cluster.

Ref.: Configuration file - Percona Backup for MongoDB


Thanks for the reply, tried to run everything from one of the cfg servers:

sorry its a screenshot, but im working with airgapped, so only way i could get it out at this point :slight_smile:

Hi @Pjotz ,

Kindly share the below details -

  1. pbm status output.
  2. MongoDB connection URI for pbm CLI (PBM_MONGODB_URI).
  3. pbm logs.


Thanks for the swift reply,
I´m a lot closer now, have gotten the backup running and everything is almost good :slight_smile:

Only issue I´m facing now, is that I´m running percona mongodb server, in my dockerfile i install the pbm-agent. Created a shell script, that starts the pbm-agent, and put it in /docker-entrypoint-initdb.d and mounted the backup folder via docker-compose.
Everything on the config servers are running like a charm. but the data nodes aint running the entrypoint script, because the database is initialised (i can see in the script that is the case).
So how is it intended to start the pbm-agent inside the containers when they start up?