> This page location: /docs.md > /docs/management.md > /docs/manual/core/backups.md > /docs/manual/administration/backup-sharded-clusters.md

> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

# Restore a Self-Managed Sharded Cluster from Database Dumps

[`mongorestore`](https://www.mongodb.com/docs/database-tools/mongorestore.md#std-program-mongorestore) is a tool that reads [`mongodump`](https://www.mongodb.com/docs/database-tools/mongodump.md#std-program-mongodump) binary exports and restores the data to a MongoDB deployment. Use [`mongorestore`](https://www.mongodb.com/docs/database-tools/mongorestore.md#std-program-mongorestore) to restore a sharded cluster from a [`mongodump`](https://www.mongodb.com/docs/database-tools/mongodump.md#std-program-mongodump) backup.

## Before you Begin

Ensure you have a [`mongodump`](https://www.mongodb.com/docs/database-tools/mongodump.md#std-program-mongodump) backup of your source cluster. To create one, see [Back Up a Self-Managed Sharded Cluster with a Database Dump](https://www.mongodb.com/docs/manual/tutorial/backup-sharded-cluster-with-database-dumps.md#std-label-backup-sharded-dumps). If you have file system snapshots, see [Restore a Self-Managed Sharded Cluster from Snapshots.](https://www.mongodb.com/docs/manual/tutorial/restore-sharded-cluster.md#std-label-restore-sharded-cluster)

## Steps

1. Stop the balancer.

   To prevent chunk migrations from disrupting the restore, connect to [`mongos`](https://www.mongodb.com/docs/manual/reference/program/mongos.md#std-program-mongos) and stop the balancer:

   ```javascript
   sh.stopBalancer()
   ```

   To verify that you stopped the balancer, run:

   ```javascript
   use config
   while( sh.isBalancerRunning().mode != "off" ) {
      print( "Waiting for Balancer to stop..." );
      sleep( 1000 );
   }
   ```

2. Pre-shard collections on the destination cluster.

   For each sharded collection in the source cluster, create the collection on the destination cluster and shard it using the same shard key before restoring data.

   To find the shard key for each collection, query the live source cluster:

   ```javascript
   use config
   db.collections.find()
   ```

   Alternatively, you can use [`bsondump`](https://www.mongodb.com/docs/database-tools/bsondump.md#mongodb-binary-bin.bsondump) to inspect the `config/collections.bson` file from your dump directory:

   ```bash
   bsondump /path/to/dump/config/collections.bson
   ```

   **Output:**

   ```json
   {
     "_id": "<database>.<collection>",
     ...
     "key": { "<shardKeyField>": "<key>" },
     ...
   }
   ```

   **Note:**

   Valid shard key values are `1` or `"hashed"`.

   For each sharded collection, shard the collection on the destination cluster using the same shard key:

   ```javascript
   sh.shardCollection(
      "<database-name>.<collection-name>",
      { <shardKeyField>: <key> }
   )
   ```

3. Restore the cluster.

   Use [`mongorestore`](https://www.mongodb.com/docs/database-tools/mongorestore.md#std-program-mongorestore) to connect to [`mongos`](https://www.mongodb.com/docs/manual/reference/program/mongos.md#std-program-mongos) and restore the cluster. Exclude the `config` database to preserve the destination cluster's existing configuration:

   ```bash
   mongorestore \
      --host <host> \
      --port 27017 \
      --username <username> \
      --password "<password>" \
      --authenticationDatabase admin \
      --nsExclude='config.*' \
      /path/to/backup
   ```

   **Important:**

   The `--drop` option drops the collection before restoring. If you use `--drop` after pre-sharding collections, [`mongorestore`](https://www.mongodb.com/docs/database-tools/mongorestore.md#std-program-mongorestore) removes the sharding configuration.

4. Restart the balancer.

   After the restore completes, restart the balancer:

   ```javascript
   sh.startBalancer()
   ```

   To confirm that the balancer is running:

   ```javascript
   sh.isBalancerRunning().mode
   ```

   **Output:**

   ```javascript
   full
   ```

5. Validate cluster accessibility.

   Connect to [`mongos`](https://www.mongodb.com/docs/manual/reference/program/mongos.md#std-program-mongos) and run [`sh.status()`](https://www.mongodb.com/docs/manual/reference/method/sh.status.md#mongodb-method-sh.status) to check the overall cluster status:

   ```javascript
   sh.status()
   ```

   To confirm that all shards are accessible and communicating, insert a test document into a temporary collection:

   ```javascript
   db.testRestore.insertOne({ test: 1 })
   ```

   Then connect to each shard primary and run [`db.collection.find()`](https://www.mongodb.com/docs/manual/reference/method/db.collection.find.md#mongodb-method-db.collection.find) to confirm that the document is present:

   ```javascript
   db.testRestore.find()
   ```

## Learn More

- [Backup and Restore a Self-Managed Sharded Cluster](https://www.mongodb.com/docs/manual/administration/backup-sharded-clusters.md#std-label-backup-restore-sharded-clusters)

- [Back Up a Self-Managed Sharded Cluster with a Database Dump](https://www.mongodb.com/docs/manual/tutorial/backup-sharded-cluster-with-database-dumps.md#std-label-backup-sharded-dumps)

- [Restore a Self-Managed Sharded Cluster from Snapshots](https://www.mongodb.com/docs/manual/tutorial/restore-sharded-cluster.md#std-label-restore-sharded-cluster)
