I am trying to backup mongoDB database using mongodump from replicaset. Script I am using works fine to dump db from remote to local. Same script errors out saying authentication failed when I trying to dump from replicaset.
Is there a simple way I can have whole db dump otherwise specific db dump will be preferred.
#!/bin/bash
HOST="mongorep1:27017,mongorep2:27017,mongorep3:27017"
REMOTE_DB="Products"
LOCAL_DB="Products"
USER="AppUser"
PASS="password"
## DUMP THE REMOTE
echo "Dumping '$HOST:$PORT/$REMOTE_DB'..."
mongodump --host $HOST --db $REMOTE_DB -u $USER -p $PASS --out dump/`date +"%m-%d-%y"`
echo "Done."
Thanks
When using replicaset with mongodump, you need to prefix the string pass to --host
with the replicaset name. For instance if your replicaset name is myreplicaset_name
then it should look like -
HOST="myreplicaset_name/mongorep1:27017,mongorep2:27017,mongorep3:27017"