OPTIONS

Restore a Sharded Cluster

Overview

The procedure outlined in this document addresses how to restore an entire sharded cluster. For information on related backup procedures consider the following tutorials which describe backup procedures in greater detail:

The exact procedure used to restore a database depends on the method used to capture the backup. See the MongoDB Backup Methods document for an overview of backups with MongoDB and Backup and Restore Sharded Clusters for a complete information on backups in MongoDB and backups of sharded clusters in particular.

Procedure

  1. Stop all mongos and mongod processes, including all shards and all config servers.

  2. Restore the following:

    • Data files for each server in each shard. Because replica sets provide each production shard, restore all the members of the replica set or use the other standard approaches for restoring a replica set from backup. See the Restore a Snapshot and Restore a Database with mongorestore sections for details on these procedures.
    • Data files for each config server.
  3. Restart all the config servers mongod instances by issuing command similar to the following, using values appropriate to your configuration:

    mongod --configsvr --dbpath /data/configdb --port 27019
    
  4. If shard hostnames have changed:

    1. Start one mongos instance, using the updated config string with the new configdb hostnames and ports.
    2. Update the shards collection in the Config Database to reflect the new hostnames.
    3. Stop the mongos instance.
  5. Restart all the shard mongod instances.

  6. Restart all the mongos instances, making sure to use the updated config string.

  7. Connect to a mongos instance from a mongo shell and use the db.printShardingStatus() method to ensure that the cluster is operational, as follows:

    db.printShardingStatus()
    show collections