Skip to content

Commit 191d335

Browse files
committed
DOCS-1960: updates mongoexport, mongoimport, mongofiles with auth reqs
- updates mongoexport, mongoimport, mongorestore, mongodump, and mongofiles to include the permissions required to run them against a mongodb database with auth enabled - pulls out-of-date 'building the tools' section from mongosniff - adds item to compatibility notes about deprecation of --journal for tools - updates backup with mongodump tutorial to not use deprecated option
1 parent fb64254 commit 191d335

15 files changed

+93
-63
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
To backup all the databases in a cluster via :program:`mongodump`, you
1+
To back up all the databases in a cluster via :program:`mongodump`, you
22
should have the :authrole:`backup` role. The :authrole:`backup` role provides
33
the required privileges for backing up all databases. The role confers no
44
additional access, in keeping with the policy of :term:`least privilege`.
55

6-
To backup a given database, you must have ``read`` access on the database.
6+
To back up a given database, you must have ``read`` access on the database.
77
Several roles provide this access, including the :authrole:`backup` role.
88

99
.. include:: /includes/fact-required-access-for-backup-profiling.rst
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
.. versionchanged:: 2.6
22

3-
To backup users and :ref:`user-defined roles <user-defined-roles>` for a
3+
To back up users and :ref:`user-defined roles <user-defined-roles>` for a
44
given database, you must have access to the ``admin`` database. MongoDB
55
stores the user data and role definitions for all databases in the
66
``admin`` database.
77

8-
Specifically, to backup a given database's users, you must have the
8+
Specifically, to back up a given database's users, you must have the
99
:authaction:`find` :ref:`action <security-user-actions>` on the ``admin``
1010
database's :data:`admin.system.users` collection. The :authrole:`backup`
1111
and :authrole:`userAdminAnyDatabase` roles both provide this privilege.
1212

13-
To backup the user-defined roles on a database, you must have the
13+
To back up the user-defined roles on a database, you must have the
1414
:authaction:`find` action on the ``admin`` database's
1515
:data:`admin.system.roles` collection. Both the :authrole:`backup` and
1616
:authrole:`userAdminAnyDatabase` roles provide this privilege.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
To restore collection data to a database with authentication enabled,
2+
you must possess the appropriate user roles.
3+
4+
To restore a single database, you must possess the :authrole:`readWrite`
5+
role for that database. Alternatively, the
6+
:authrole:`readWriteAnyDatabase` provides access to restore any database.
7+
The :authrole:`restore` role also provides the requisite permissions.

source/includes/access-mongorestore.rst renamed to source/includes/access-mongorestore-users.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@ To restore user-defined roles to a database, you must have the
1414
:authaction:`insert` action on the ``admin`` database's
1515
:data:`admin.system.roles` collection. The :authrole:`restore` role
1616
provides this privilege.
17+
18+
If your database is running with authentication enabled, you must
19+
possess the :authrole:`userAdmin` role on the database you are
20+
restoring, or the :authrole:`userAdminAnyDatabase` role, which allows
21+
you to restore user data to any database. The :authrole:`restore` role
22+
also provides the requisite privileges.

source/includes/fact-required-access-for-backup-profiling.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
To backup the :data:`system.profile <<database>.system.profile>`
1+
To back up the :data:`system.profile <<database>.system.profile>`
22
collection, which is created when you activate :ref:`database profiling
33
<database-profiling>`, you must have **additional**
44
``read`` access on this collection. Several

source/reference/program/mongodump.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ from :term:`secondary` members of the set.
4444
Required Access
4545
---------------
4646

47-
Backup Collections
48-
~~~~~~~~~~~~~~~~~~
47+
Back Up Collections
48+
~~~~~~~~~~~~~~~~~~~
4949

5050
.. include:: /includes/access-mongodump-collections.rst
5151

52-
Backup Users
53-
~~~~~~~~~~~~
52+
Back Up Users
53+
~~~~~~~~~~~~~
5454

5555
.. include:: /includes/access-mongodump-users.rst
5656

source/reference/program/mongoexport.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ data type information. Use :program:`mongodump` and
2626
:program:`mongorestore` as described in :doc:`/core/backups` for this
2727
kind of functionality.
2828

29+
Required Access
30+
---------------
31+
32+
In order to connect to a :program:`mongod` that enforces authorization
33+
with the :option:`--auth <mongod --auth>` option, you must use the
34+
:option:`--username <mongoexport --username>` and :option:`--password
35+
<mongoexport --password>` options. The connecting user must possess at a
36+
minimum, the :authrole:`read` role on the database that they are exporting.
37+
2938
Options
3039
-------
3140

@@ -192,7 +201,7 @@ shell uses the :doc:`mongoShell mode representation
192201
.. code-block:: javascript
193202

194203
use test
195-
db.traffic.insert( { _id: 1, volume: NumberLong(2980000), date: new Date() } )
204+
db.traffic.insert( { _id: 1, volume: NumberLong("2980000"), date: new Date() } )
196205

197206
Use :program:`mongoexport` to export the data:
198207

source/reference/program/mongofiles.txt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,22 @@ stored in a MongoDB data directory without requiring a running
4242

4343
.. important:: For :term:`replica sets <replica set>`,
4444
:program:`mongofiles` can only read from the set's
45-
':term:`primary`.
45+
:term:`primary`.
46+
47+
Required Access
48+
---------------
49+
50+
In order to connect to a :program:`mongod` that enforces authorization
51+
with the :option:`--auth <mongod --auth>` option, you must use the
52+
:option:`--username <mongofiles --username>` and :option:`--password
53+
<mongofiles --password>` options. The connecting user must possess, at a
54+
minimum:
55+
56+
- the :authrole:`read` role for the accessed database when using the
57+
``list``, ``search`` or ``get`` commands,
58+
59+
- the :authrole:`readWrite` role for the accessed database when using
60+
the ``put`` or ``delete`` commands.
4661

4762
.. _mongofiles-options:
4863

@@ -109,7 +124,6 @@ Options
109124

110125
.. include:: /includes/option/option-mongofiles-writeConcern.rst
111126

112-
113127
.. _mongofiles-commands:
114128

115129
Commands

source/reference/program/mongoimport.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ functionality.
3131
a time into MongoDB. Custom import tools for data ingestion may have
3232
better performance for specific workloads.
3333

34+
Required Access
35+
---------------
36+
37+
In order to connect to a :program:`mongod` that enforces authorization
38+
with the :option:`--auth <mongod --auth>` option, you must use the
39+
:option:`--username <mongoexport --username>` and :option:`--password
40+
<mongoexport --password>` options. The connecting user must
41+
possess, at a minimum, the :authrole:`readWrite` role on the database
42+
into which they are importing data.
43+
3444
Options
3545
-------
3646

source/reference/program/mongorestore.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,18 @@ Remember the following properties of :program:`mongorestore` behavior:
4848
.. versionadded:: 3.0.0
4949
:program:`mongorestore` also accepts input via standard input.
5050

51-
Required Access to Restore User Data
52-
------------------------------------
51+
Required Access
52+
---------------
5353

54-
.. include:: /includes/access-mongorestore.rst
54+
Restore Collection Data
55+
~~~~~~~~~~~~~~~~~~~~~~~
56+
57+
.. include:: /includes/access-mongorestore-collections.rst
58+
59+
Restore Users and User Data
60+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
61+
62+
.. include:: /includes/access-mongorestore-users.rst
5563

5664
Options
5765
-------

source/reference/program/mongosniff.txt

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Synopsis
1212
:program:`mongosniff` provides a low-level operation tracing/sniffing view
1313
into database activity in real time. Think of :program:`mongosniff` as a
1414
MongoDB-specific analogue of ``tcpdump`` for TCP/IP network
15-
traffic. Typically, :program:`mongosniff` is most frequently used in driver
15+
traffic. :program:`mongosniff` is most frequently used in driver
1616
development.
1717

1818
.. _mongosniff-libcap:
@@ -64,34 +64,6 @@ interface and port 27018, for driver development and troubleshooting:
6464

6565
mongosniff --objcheck --source NET lo 27018
6666

67-
Build ``mongosniff``
68-
--------------------
69-
70-
To build ``mongosniff`` yourself, Linux users can use the following
71-
procedure:
72-
73-
1. Obtain prerequisites using your operating
74-
systems package management software. Dependencies include:
75-
76-
- ``libpcap`` - to capture network packets.
77-
- ``git`` - to download the MongoDB source code.
78-
- ``scons`` and a C++ compiler - to build :program:`mongosniff`.
79-
80-
2. Download a copy of the MongoDB source code using ``git``:
81-
82-
.. code-block:: sh
83-
84-
git clone git://github.com/mongodb/mongo.git
85-
86-
3. Issue the following sequence of commands to change to the
87-
``mongo/`` directory and build :program:`mongosniff`:
88-
89-
.. code-block:: sh
90-
91-
cd mongo
92-
scons mongosniff
93-
94-
.. note::
95-
96-
If you run ``scons mongosniff`` before installing ``libpcap`` you
97-
must run ``scons clean`` before you can build :program:`mongosniff`.
67+
.. seealso::
68+
To build :program:`mongosniff` yourself, see: :about:`Build MongoDB
69+
Tools From Source </contributors/tutorial/build-tools-from-source>`.

source/reference/program/mongostat.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ UNIX/Linux file system utility ``vmstat``, but provides data regarding
3232
For an additional utility that provides MongoDB metrics see
3333
:doc:`mongotop </reference/program/mongotop>`.
3434

35-
Access Control Requirements
36-
---------------------------
35+
Required Access
36+
---------------
3737

3838
In order to connect to a :program:`mongod` that enforces authorization
3939
with the :option:`--auth <mongod --auth>` option, specify the

source/reference/program/mongotop.txt

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,6 @@ MongoDB instance spends reading and writing data. :program:`mongotop`
1616
provides statistics on a per-collection level. By default,
1717
:program:`mongotop` returns values every second.
1818

19-
.. important:: In order to connect to a :program:`mongod` that enforces
20-
authorization with the :option:`--auth <mongod --auth>` option, the
21-
:option:`--username <mongotop --username>` and
22-
:option:`--password <mongotop --password>` options must be used, and the
23-
user specified must have the :authaction:`serverStatus` and
24-
:authaction:`top` privileges.
25-
26-
The most appropriate built-in role that has these privileges is
27-
:authrole:`clusterMonitor`.
28-
2919
.. seealso::
3020

3121
For more information about monitoring MongoDB, see
@@ -42,6 +32,18 @@ provides statistics on a per-collection level. By default,
4232
For an additional utility that provides MongoDB metrics
4333
see :doc:`mongostat </reference/program/mongostat>`.
4434

35+
Required Access
36+
---------------
37+
38+
In order to connect to a :program:`mongod` that enforces authorization
39+
with the :option:`--auth <mongod --auth>` option, you must use the
40+
:option:`--username <mongotop --username>` and :option:`--password
41+
<mongotop --password>` options, and the user specified must
42+
have the :authaction:`serverStatus` and :authaction:`top` privileges.
43+
44+
The most appropriate built-in role that has these privileges is
45+
:authrole:`clusterMonitor`.
46+
4547
.. _mongotop-options:
4648

4749
Options

source/release-notes/3.0-compatibility.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ instance(s) before using these tools.
249249
Removed Options
250250
~~~~~~~~~~~~~~~
251251

252-
- Removed ``--dbpath`` and ``--filter`` options for
253-
:program:`mongorestore`, :program:`mongoimport`,
252+
- Removed ``--dbpath``, ``--journal``, and ``--filter`` options for
253+
:program:`mongodump`, :program:`mongorestore`, :program:`mongoimport`,
254254
:program:`mongoexport`, and :program:`bsondump`.
255255

256256
- Removed ``--locks`` option for :program:`mongotop`.

source/tutorial/backup-with-mongodump.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ and password credentials to specify database authentication.
122122
Restore a Database with ``mongorestore``
123123
----------------------------------------
124124

125-
.. include:: /includes/access-mongorestore.rst
125+
.. include:: /includes/access-mongorestore-collections.rst
126+
127+
.. include:: /includes/access-mongorestore-users.rst
126128

127129
Basic ``mongorestore`` Operations
128130
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)