mongodump -h 127.0.0.1 -d mydb -u carlos -p -o /var/lib/mongodb/backups
Hi Carlos,
I have a replSet cluster running x2 MongoDB servers and an arbiter on a production Linux (CentOS 7.2) servers. I need to configure automated backups of the replSet but obviously I would need some kind of logic inside my script to detect rs.isMaster() & then perform a dump as follows:
Do I understand correctly that you want to perform mongodump
on a Secondary?
In MongoDB 3.0 and earlier, mongodump
will always perform the dump from Secondaries if connected to a replica set.
This was changed in MongoDB 3.2, where mongodump
defaults to Primary instead. In MongoDB 3.2, you can set the --readPreference
setting to dump from Secondaries if you wish, giving you more flexibility. For example (if you are using MongoDB 3.2):
mongodump -h 127.0.0.1 -d mydb -u carlos -p -o /var/lib/mongodb/backups --readPreference=secondary
Please see mongodump read preference page for more details.
Also, please note that dumping from Secondaries is not recommended for a sharded cluster deployment. This is because Secondaries are eventually consistent with the Primary, and in a sharded cluster this could result in an inconsistent backup state.
Best regards,
Kevin
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to a topic in the Google Groups "mongodb-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mongodb-user/rGwizI-g3dY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mongodb-user+unsubscribe@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/42fc8f1a-689f-457e-b7cc-7283a129e9fb%40googlegroups.com.