- Sharding >
- Backup a Small Sharded Cluster with
mongodump
Backup a Small Sharded Cluster with mongodump
¶
Overview¶
If your sharded cluster holds a small data set, you can
connect to a mongos
using mongodump
. You can
create backups of your MongoDB cluster, if your backup infrastructure
can capture the entire backup in a reasonable amount of time and if
you have a storage system that can hold the complete MongoDB data set.
Read Sharded Cluster Backup Considerations for a high-level overview of important considerations as well as a list of alternate backup tutorials.
Important
By default mongodump
issue its queries to
the non-primary nodes.
Procedure¶
Capture Data¶
Note
If you use mongodump
without specifying a database
or collection, mongodump
will capture collection data
and the cluster meta-data from the config servers.
You cannot use the --oplog
option for
mongodump
when capturing data from
mongos
. This option is only available when running
directly against a replica set member.
You can perform a backup of a sharded cluster by connecting
mongodump
to a mongos
. Use the following
operation at your system’s prompt:
mongodump
will write BSON files that hold a copy of
data stored in the sharded cluster accessible via the
mongos
listening on port 27017
of the
mongos3.example.net
host.
Restore Data¶
Backups created with mongodump
do not reflect the chunks or
the distribution of data in the sharded collection or
collections. Like all mongodump
output, these backups
contain separate directories for each database and BSON files
for each collection in that database.
You can restore mongodump
output to any MongoDB instance,
including a standalone, a replica set, or a new
sharded cluster. When restoring data to sharded cluster, you
must deploy and configure sharding before restoring data from the
backup. See Deploy a Sharded Cluster for more information.