Server Selection Error timeout

Hi,
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://172.25.0.7:27017” --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
1
+ 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: 127.0.0.1:27017, Type: Unknown, Last error: dial tcp 127.0.0.1:27017: connect: connection refused }, ] }

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

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

/Morten

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

Regards,
Parag

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.

Regards,
Parag

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 entrypoint.sh script that is the case).
So how is it intended to start the pbm-agent inside the containers when they start up?

/Morten