In sharded replicas before backup process you need to disable balancer and when backup finishes you need to enable the balancer.
This process doesn’t defer if you use snapshot or use dump backups.
You can use crontab jobs to automatize the backup process. You can use the sh script given below for your backup processes:
disableBalancer.js
1 2 | use config sh.stopBalancer() |
disableBalancer.sh
1 2 | #!/bin/sh mongo --port 27017 --username "username" -p "password" --authenticationDatabase admin < disableBalancer.js |
enableBalancer.js
1 2 3 | use config sh.setBalancerState(true) |
enableBalancer.sh
1 2 | #!/bin/bash mongo --port 27017 --username "username" -p "password" --authenticationDatabase admin < enableBalancer.js |