Skip to content

Commit 3f7cb93

Browse files
authored
DOCSP-50132: Syntax (#12072)
* DOCSP-49949 * DOCSP-49944 * syntax section * feedback
1 parent 129e378 commit 3f7cb93

File tree

1 file changed

+45
-29
lines changed

1 file changed

+45
-29
lines changed

content/database-tools/source/mongorestore.txt

Lines changed: 45 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,32 @@ the MongoDB Database Tools.
5656
Syntax
5757
------
5858

59-
``mongorestore`` syntax:
59+
Use the following command syntax when you run ``mongorestore``:
6060

6161
.. code-block:: sh
6262

6363
mongorestore <options> <connection-string> <directory or file to restore>
6464

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:
6779

6880
.. code-block:: sh
6981

70-
mongorestore dump/
82+
mongorestore --uri="<my-connection-string>" ./downloads/dump
7183

72-
As ``mongorestore`` restores from the ``dump/`` directory,
84+
As ``mongorestore`` restores from the provided directory,
7385
it creates the database and collections as needed and logs its progress:
7486

7587
.. code-block:: sh
@@ -89,39 +101,41 @@ it creates the database and collections as needed and logs its progress:
89101
2019-07-08T14:37:39.249-0400 31 document(s) restored successfully. 0 document(s) failed to restore.
90102

91103
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``
94106
directory:
95107

96108
.. code-block:: sh
97109

98-
mongorestore --nsInclude=test.purchaseorders dump/
110+
mongorestore --nsInclude=test.purchaseorders ./dump
99111

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:
104116

105117
.. code-block:: sh
106118

107119
mongorestore --nsInclude=foo.bar dump/
108120

109-
The ``mongorestore`` outputs the following messages:
121+
``mongorestore`` outputs the following messages:
110122

111123
.. code-block:: sh
112124
:copyable: false
113125

114126
2019-07-08T14:38:15.142-0400 preparing collections to restore from
115127
2019-07-08T14:38:15.142-0400 0 document(s) restored successfully. 0 document(s) failed to restore.
116128

117-
For more examples, see :ref:`mongorestore-examples`.
129+
For more ``mongorestore`` examples, see :ref:`mongorestore-examples`.
118130

119-
120131
.. _mongorestore-options:
121132

122133
Options
123134
-------
124135

136+
This section includes information about all available options for
137+
``mongorestore``.
138+
125139
.. option:: --help
126140

127141
Returns information on the options and use of ``mongorestore``.
@@ -141,6 +155,8 @@ Options
141155
of output.
142156

143157
This option suppresses:
158+
159+
- errors
144160

145161
- output from :term:`database commands <database command>`
146162

@@ -404,7 +420,13 @@ Options
404420

405421
.. option:: --db=<database>, -d=<database>
406422

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+
408430
Specifies the destination database for ``mongorestore`` to restore data
409431
*into* when restoring from a BSON file. If the database does not
410432
exist, ``mongorestore`` creates the database. For example, the following
@@ -418,17 +440,17 @@ Options
418440
If you do not specify :option:`--db`, ``mongorestore`` reads the database name
419441
from the data files.
420442

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-
426443
.. include:: /includes/extracts/uri-used-with-db.rst
427444

428-
429445
.. option:: --collection=<collection>, -c=<collection>
430446

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+
432454
Specifies the name of the destination collection for ``mongorestore`` to
433455
restore data *into* when restoring from a BSON file. If
434456
you do not specify :option:`--collection`, ``mongorestore`` takes
@@ -440,12 +462,6 @@ Options
440462
:copyable: false
441463

442464
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-
449465

450466
.. option:: --nsExclude=<namespace pattern>
451467

0 commit comments

Comments
 (0)