@@ -56,20 +56,32 @@ the MongoDB Database Tools.
56
56
Syntax
57
57
------
58
58
59
- ``mongorestore`` syntax :
59
+ Use the following command syntax when you run ``mongorestore``:
60
60
61
61
.. code-block:: sh
62
62
63
63
mongorestore <options> <connection-string> <directory or file to restore>
64
64
65
- For example, to restore from a ``dump`` directory to a local
66
- :binary:`~bin.mongod` instance running on port ``27017``:
65
+ See :ref:`mongorestore-options` for what options you can use when you run
66
+ ``mongorestore``.
67
+
68
+ When you run ``mongorestore`` with no arguments, the default setting is to
69
+ restore data from a local ``./dump`` directory to a local :binary:`~bin.mongod`
70
+ instance running on port ``27027``:
71
+
72
+ .. code-block:: sh
73
+
74
+ mongorestore
75
+
76
+ You can also specify a ``dump`` directory at a different path. For example,
77
+ the following command restores data from a directory at ``./downloads/dump``
78
+ to an Atlas cluster specified by a connection string:
67
79
68
80
.. code-block:: sh
69
81
70
- mongorestore dump/
82
+ mongorestore --uri="<my-connection-string>" ./downloads/dump
71
83
72
- As ``mongorestore`` restores from the ``dump/`` directory,
84
+ As ``mongorestore`` restores from the provided directory,
73
85
it creates the database and collections as needed and logs its progress:
74
86
75
87
.. code-block:: sh
@@ -89,39 +101,41 @@ it creates the database and collections as needed and logs its progress:
89
101
2019-07-08T14:37:39.249-0400 31 document(s) restored successfully. 0 document(s) failed to restore.
90
102
91
103
You can also restore a specific collection or collections from the
92
- ``dump/ `` directory. For example, the following operation restores a
93
- single collection from corresponding data files in the ``dump/ ``
104
+ ``dump`` directory. For example, the following operation restores the
105
+ ``test.purchaseorders`` collection from corresponding data files in the ``dump``
94
106
directory:
95
107
96
108
.. code-block:: sh
97
109
98
- mongorestore --nsInclude=test.purchaseorders dump/
110
+ mongorestore --nsInclude=test.purchaseorders ./dump
99
111
100
- If the ``dump/ `` directory does not contain the corresponding data file
101
- for the specified namespace, no data will be restored. For example, the
102
- following specifies a collection namespace that does not have a
103
- corresponding data in the ``dump/ `` directory:
112
+ If the ``dump`` directory does not contain the corresponding data file
113
+ for the specified namespace, ``mongorestore`` does not restore any data.
114
+ For example, the following command specifies a collection namespace
115
+ that does not have corresponding data in the ``dump`` directory:
104
116
105
117
.. code-block:: sh
106
118
107
119
mongorestore --nsInclude=foo.bar dump/
108
120
109
- The ``mongorestore`` outputs the following messages:
121
+ ``mongorestore`` outputs the following messages:
110
122
111
123
.. code-block:: sh
112
124
:copyable: false
113
125
114
126
2019-07-08T14:38:15.142-0400 preparing collections to restore from
115
127
2019-07-08T14:38:15.142-0400 0 document(s) restored successfully. 0 document(s) failed to restore.
116
128
117
- For more examples, see :ref:`mongorestore-examples`.
129
+ For more ``mongorestore`` examples, see :ref:`mongorestore-examples`.
118
130
119
-
120
131
.. _mongorestore-options:
121
132
122
133
Options
123
134
-------
124
135
136
+ This section includes information about all available options for
137
+ ``mongorestore``.
138
+
125
139
.. option:: --help
126
140
127
141
Returns information on the options and use of ``mongorestore``.
@@ -141,6 +155,8 @@ Options
141
155
of output.
142
156
143
157
This option suppresses:
158
+
159
+ - errors
144
160
145
161
- output from :term:`database commands <database command>`
146
162
@@ -404,7 +420,13 @@ Options
404
420
405
421
.. option:: --db=<database>, -d=<database>
406
422
407
-
423
+ .. important::
424
+
425
+ The use of :option:`--db` and :option:`--collection` options are
426
+ deprecated when restoring from a directory or an archive file.
427
+ To restore from an archive or a directory, see
428
+ :option:`--nsInclude`.
429
+
408
430
Specifies the destination database for ``mongorestore`` to restore data
409
431
*into* when restoring from a BSON file. If the database does not
410
432
exist, ``mongorestore`` creates the database. For example, the following
@@ -418,17 +440,17 @@ Options
418
440
If you do not specify :option:`--db`, ``mongorestore`` reads the database name
419
441
from the data files.
420
442
421
- The use of :option:`--db` and :option:`--collection` options are
422
- deprecated when restoring from a directory or an archive file.
423
- Instead, to restore from an archive or a directory, see
424
- :option:`--nsInclude` instead.
425
-
426
443
.. include:: /includes/extracts/uri-used-with-db.rst
427
444
428
-
429
445
.. option:: --collection=<collection>, -c=<collection>
430
446
431
-
447
+ .. important::
448
+
449
+ The use of :option:`--db` and :option:`--collection` options are
450
+ deprecated when restoring from a directory or an archive file.
451
+ To restore from an archive or a directory, see
452
+ :option:`--nsInclude`.
453
+
432
454
Specifies the name of the destination collection for ``mongorestore`` to
433
455
restore data *into* when restoring from a BSON file. If
434
456
you do not specify :option:`--collection`, ``mongorestore`` takes
@@ -440,12 +462,6 @@ Options
440
462
:copyable: false
441
463
442
464
mongorestore --db=reporting --collection=employeesalaries dump/test/salaries.bson
443
-
444
- The use of :option:`--db` and :option:`--collection` options are
445
- deprecated when restoring from a directory or an archive file.
446
- Instead, to restore from an archive or a directory, see
447
- :option:`--nsInclude` instead.
448
-
449
465
450
466
.. option:: --nsExclude=<namespace pattern>
451
467
0 commit comments