MongoDB Documentation, Release 3.0.4 Overview This document describes a procedure for taking a backup of all components of a sharded cluster. This procedure uses mongodump to create dumps of the mongod instance. An alternate procedure uses file system snap- shots to capture the backup data, and may be more efficient in some situations if your system configuration allows file system backups. See Backup and Restore Sharded Clusters (page 254) for more information. See MongoDB Backup Methods (page 184) and Backup and Restore Sharded Clusters (page 254) for complete infor- mation on backups in MongoDB and backups of sharded clusters in particular. Prerequisites Important: To capture a point-in-time backup from a sharded cluster you must stop all writes to the cluster. On a running production system, you can only capture an approximation of point-in-time snapshot. To back up all the databases in a cluster via mongodump , you should have the backup (page 410) role. The backup (page 410) role provides the required privileges for backing up all databases. The role confers no additional access, in keeping with the policy of least privilege . To back up a given database, you must have read access on the database. Several roles provide this access, including the backup (page 410) role. To back up the system.profile (page 291) collection, which is created when you activate database profiling (page 215), you must have additional read access on this collection. Several roles provide this access, including the clusterAdmin (page 408) and dbAdmin (page 406) roles. Changed in version 2.6. To back up users and user-defined roles (page 325) for a given database, you must have access to the admin database. MongoDB stores the user data and role definitions for all databases in the admin database. Specifically, to back up a given database’s users, you must have the find (page 419) action (page 419) on the admin database’s admin.system.users (page 291) collection. The backup (page 410) and userAdminAnyDatabase (page 412) roles both provide this privilege. To back up the user-defined roles on a database, you must have the find (page 419) action on the admin database’s admin.system.roles (page 291) collection. Both the backup (page 410) and userAdminAnyDatabase (page 412) roles provide this privilege. Consideration To create these backups of a sharded cluster, you will stop the cluster balancer and take a backup of the config database , and then take backups of each shard in the cluster using mongodump to capture the backup data. To capture a more exact moment-in-time snapshot of the system, you will need to stop all application writes before taking the filesystem snapshots; otherwise the snapshot will only approximate a moment in time. For approximate point-in-time snapshots, taking the backup from a single offline secondary member of the replica set that provides each shard can improve the quality of the backup while minimizing impact on the cluster. Procedure Step 1: Disable the balancer process. Disable the balancer process that equalizes the distribution of data among the shards . To disable the balancer, use the sh.stopBalancer() method in the mongo shell. For example: Chapter 5. Administration 258 use config sh.setBalancerState( true ) Backup a Sharded Cluster with Database Dumps