How it works...
Taking backups of a sharded cluster is a bit nuanced, as it involves ensuring certain steps are considered before planning a backup strategy. For starters, we need to stop the balancer. We begin by connecting to mongos server and stopping the balancer, as shown in step 1. Next, in step 2, we use mongodump to take a backup of the config server. In a production environment, prior to executing a mongodump, it is suggested to connect to the config server replica set secondary, issue a db.fsyncLock() and rs.slaveOk(). This ensures that there are no writes to the config database, of the given replica set and we are able to read from it. Next, in step 3, we connect to each shard (our example only has one shard member) and execute ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access