In this recipe, we will be looking at how to restore a sharded cluster from a previously generated backup.
You will need a sharded cluster, with a minimum of a config server replica set (CSRS) and one shard. Refer to the Setting up and configuring a sharded cluster recipe in Chapter 5, High Scalability with Sharding, on how to create a sharded cluster.
Additionally, we will also need a previously generated backup from a sharded cluster; you can refer to the Creating a backup of a sharded cluster recipe in Chapter 6, Managing MogoDB Backups.
- Shut down the mongos server.
- Restore the shards one by one:
mongorestore -h 192.168.200.200 -p 27027 --drop --dir /backups/shard1bkp/
- Shut down the shards.
- Restore the config server:
mongorestore -h 192.168.200.200 -p 27019 --drop --dir /backups/configbkp/
- Start the shards and the mongos servers.