Skip to content

Commit 266fbdd

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 266fbdd

15 files changed

+94
-64
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+
the connecting user must possess the appropriate user roles.
3+
4+
To restore a single database, the connecting user 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
-------

0 commit comments

Comments
 (0)