macOS Sierra and Go 1.6 Incompatibility
Users running on macOS Sierra require the 3.2.10 or newer version of mongorestore.
For example, to restore from a
dump directory to a local
mongod instance running on port
mongorestore restores from the
dump/ directory, it creates the database and collections as needed and logs its progress:
You can also restore a specific collection or collections from the
dump/ directory. For example, the following operation restores a single collection from corresponding data files in the
dump/ directory does not contain the corresponding data file for the specified namespace, no data will be restored. For example, the following specifies a collection namespace that does not have a corresponding data in the
mongorestore outputs the following messages:
For more examples, see Examples.
For more information on the options and arguments, see Options.
mongorestore can create a new database or add data to an existing database. However,
mongorestore performs inserts only and does not perform updates. That is, if restoring documents to an existing database and collection and existing documents have the same value
_id field as the to-be-restored documents,
mongorestore will not overwrite those documents.
Starting in MongoDB 2.6, creating indexes will error if an index key in an existing document exceeds the limit. See Enforce Index Key Length Limit for more information and solution.
If you have an existing data set that violates this limit but want to resolve the index issue after restoring the data, you can disable the default index key length validation on the target database by setting the mongod instance’s
failIndexKeyTooLong parameter to false.
To restore data to a MongoDB deployment that has access control enabled, the
restore role provides the necessary privileges to restore data from backups if the data does not include
system.profile collection data and you run
mongorestore without the
If the backup data includes
Changed in version 3.0.0:
mongorestore removed the
--dbpath, and the
Increases the amount of internal reporting returned on standard output or in log files. Increase the verbosity with the
-vform by including the option multiple times, (e.g.
Runs mongorestore in a quiet mode that attempts to limit the amount of output.
This option suppresses:
- output from database commands
- replication activity
- connection accepted events
- connection closed events
New in version 3.4.6.
Specify a resolvable URI connection string to connect to the MongoDB deployment.
For more information on the components of the connection string, see the Connection String URI Format documentation.
The following command-line options cannot be used in conjunction with
--password(if the URI connection string also includes the password)
Instead, specify these options as part of your
Specifies a resolvable hostname for the
mongodto which to connect. By default, the mongorestore attempts to connect to a MongoDB instance running on the localhost on port number
To connect to a replica set, specify the
replSetNameand a seed list of set members, as in the following:
When specifying the replica set list format, mongorestore always connects to the primary.
You can also connect to any single member of the replica set by specifying the host and port of only that member:
Changed in version 3.0.0: If you use IPv6 and use the
<address>:<port>format, you must enclose the portion of an address and port combination in brackets (e.g.