Skip to content

DOCS-1924 access required to backup and restore user data #1509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions source/includes/access-mongodump.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.. versionchanged:: 2.6

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

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

To backup the user-defined roles on a database, you must have the
:authaction:`find` action on the ``admin`` database's
:data:`admin.system.roles` collection. Both the :authrole:`backup` and
:authrole:`userAdminAnyDatabase` roles provide this privilege.
16 changes: 16 additions & 0 deletions source/includes/access-mongorestore.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.. versionchanged:: 2.6

To restore users and :ref:`user-defined roles <user-defined-roles>` on a
given database, you must have access to the ``admin`` database. MongoDB
stores the user data and role definitions for all databases in the
``admin`` database.

Specifically, to restore users to a given database, you must have the
:authaction:`insert` :ref:`action <security-user-actions>` on the ``admin``
database's :data:`admin.system.users` collection. The :authrole:`restore`
role provides this privilege.

To restore user-defined roles to a database, you must have the
:authaction:`insert` action on the ``admin`` database's
:data:`admin.system.roles` collection. The :authrole:`restore` role
provides this privilege.
3 changes: 1 addition & 2 deletions source/includes/fact-mongodump-local-database.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
.. important:: :program:`mongodump` does *not* dump the content of the
``local`` database.
:program:`mongodump` does *not* dump the content of the ``local`` database.
10 changes: 4 additions & 6 deletions source/includes/warning-mongodump-compatibility-2.2.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.. warning::

The data format used by :program:`mongodump` from version 2.2 or
later is *incompatible* with earlier versions of :program:`mongod`.
Do not use recent versions of :program:`mongodump` to back up older
data stores.
The data format used by :program:`mongodump` from version 2.2 or
later is *incompatible* with earlier versions of :program:`mongod`.
Do not use recent versions of :program:`mongodump` to back up older
data stores.
14 changes: 11 additions & 3 deletions source/reference/program/mongodump.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,21 @@ restore databases.
instances, in addition to reading directly from MongoDB data files
without an active :program:`mongod`.

.. seealso:: :program:`mongorestore`,
:doc:`/tutorial/backup-sharded-cluster-with-database-dumps`
and :doc:`/core/backups`.

Behavior
--------

.. include:: /includes/fact-mongodump-local-database.rst

.. include:: /includes/warning-mongodump-compatibility-2.2.rst

.. seealso:: :program:`mongorestore`,
:doc:`/tutorial/backup-sharded-cluster-with-database-dumps`
and :doc:`/core/backups`.
Required Access to Backup User Data
-----------------------------------

.. include:: /includes/access-mongodump.rst

Options
-------
Expand Down
8 changes: 8 additions & 0 deletions source/reference/program/mongorestore.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ data to an existing database.
instances, in addition to writing directly to MongoDB data files
without an active :program:`mongod`.

Behavior
--------

If you restore to an existing database, :program:`mongorestore` will
only insert into the existing database, and does not perform updates
of any kind. If existing documents have the same value ``_id`` field
Expand All @@ -42,6 +45,11 @@ Remember the following properties of :program:`mongorestore` behavior:

.. include:: /includes/warning-mongodump-compatibility-2.2.rst

Required Access to Restore User Data
------------------------------------

.. include:: /includes/access-mongorestore.rst

Options
-------

Expand Down
15 changes: 11 additions & 4 deletions source/tutorial/backup-and-restore-with-binary-database-dumps.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Backup a Database with ``mongodump``

.. include:: /includes/fact-mongodump-local-database.rst

.. include:: /includes/access-mongodump.rst

Basic ``mongodump`` Operations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -131,7 +133,7 @@ Consider the following example:

.. code-block:: sh

mongodump --host mongodb1.example.net --port 3017 --username user --password pass --out /opt/backup/mongodump-2012-10-24
mongodump --host mongodb1.example.net --port 3017 --username user --password pass --out /opt/backup/mongodump-2013-10-24

On any :program:`mongodump` command you may, as above, specify username
and password credentials to specify database authentication.
Expand All @@ -141,6 +143,11 @@ and password credentials to specify database authentication.
Restore a Database with ``mongorestore``
----------------------------------------

.. include:: /includes/access-mongorestore.rst

Basic ``mongorestore`` Operations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The :program:`mongorestore` utility restores a binary backup created by
:program:`mongodump`. By default, :program:`mongorestore` looks for a
database backup in the :file:`dump/` directory.
Expand Down Expand Up @@ -175,10 +182,10 @@ Consider the following example:

.. code-block:: sh

mongorestore dump-2012-10-25/
mongorestore dump-2013-10-25/

Here, :program:`mongorestore` imports the database backup in
the :file:`dump-2012-10-25` directory to the :program:`mongod` instance
the :file:`dump-2013-10-25` directory to the :program:`mongod` instance
running on the localhost interface.

.. _backup-restore-oplogreplay:
Expand Down Expand Up @@ -274,7 +281,7 @@ Consider the following example:

.. code-block:: sh

mongorestore --host mongodb1.example.net --port 3017 --username user --password pass /opt/backup/mongodump-2012-10-24
mongorestore --host mongodb1.example.net --port 3017 --username user --password pass /opt/backup/mongodump-2013-10-24

As above, you may specify username and password connections if your
:program:`mongod` requires authentication.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ provide alternate procedures.

.. include:: /includes/note-shard-cluster-backup.rst

.. include:: /includes/access-mongodump.rst

Procedure
---------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ considerations as well as a list of alternate backup tutorials.
.. important:: By default :program:`mongodump` issue its queries to
the non-primary nodes.

.. include:: /includes/access-mongodump.rst

Procedure
---------

Expand Down