-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathmongorestore-behavior-access-usage.txt
189 lines (136 loc) · 5.96 KB
/
mongorestore-behavior-access-usage.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
.. _mongorestore-behavior-access-usage:
============================================
mongorestore Behavior, Access, and Usage
============================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
.. facet::
:name: genre
:values: reference
.. |arrow| unicode:: U+27A4
.. |tool-binary| replace:: ``mongorestore``
.. include:: /includes/warning-tools-dollar-dump-restore-restriction.rst
Behavior
--------
Restore to Matching Server Version
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. include:: /includes/fact-match-dump-restore-versions.rst
Insert Only
~~~~~~~~~~~
``mongorestore`` can create a new database or add data to an
existing database. However, ``mongorestore`` performs inserts
only and does not perform updates. If you restore documents to
an existing database and collection and existing documents have the
same value ``_id`` field as the documents to restore,
``mongorestore`` will *not* overwrite those documents.
Document Order
~~~~~~~~~~~~~~
.. |maintain-order-flag| replace:: :option:`--maintainInsertionOrder <mongorestore --maintainInsertionOrder>`
.. include:: /includes/restore-document-order.rst
Rebuild Indexes
~~~~~~~~~~~~~~~
``mongorestore`` recreates indexes recorded by
:binary:`~bin.mongodump` after restoring data.
.. note::
For MongoDB installations with ``featureCompatibilityVersion`` (FCV)
set to ``"4.0"`` or earlier, creating indexes will
error if an index key in an existing document exceeds the
limit.
To avoid this issue, consider using hashed indexes or indexing a
computed value instead. To resolve the index issue after
restoring the data, you can disable the default index key length
validation on the target database by setting the :binary:`~bin.mongod`
instance's ``failIndexKeyTooLong`` parameter to false.
Exclude ``system.profile`` Collection
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
``mongorestore`` does not restore the :data:`system.profile
<<database>.system.profile>` collection data.
FIPS
~~~~
``mongorestore`` automatically creates FIPS-compliant
connections to a :binary:`~bin.mongod`/:binary:`~bin.mongos` that is
:manual:`configured to use FIPS mode </tutorial/configure-fips>`.
Write Concern
~~~~~~~~~~~~~
If you specify write concern in both the
:option:`--writeConcern <mongorestore --writeConcern>` option and the
:option:`--uri <mongorestore --uri>` connection string option, the
:option:`--writeConcern <mongorestore --writeConcern>` value overrides
the write concern specified in the URI string.
.. _mongorestore-time-series-collections:
Time Series Collections
~~~~~~~~~~~~~~~~~~~~~~~
Starting in MongoDB 5.0, you can use ``mongorestore`` to restore
:ref:`timeseries collections <manual-timeseries-landing>`.
For details, see :ref:`mongorestore-example-time-series`.
Using ``mongorestore`` on Atlas Free and Shared Tier Clusters
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
On free (``M0``) and shared (``M2`` and ``M5``) tier Atlas clusters, the
following limitations apply:
- You can't run ``mongorestore`` on the ``admin`` database. By default,
``mongorestore`` skips this database. If you use the :option:`--db
<mongorestore --db>` option to set the destination database to
``admin``, the program returns an error.
- You can't use the following options with the ``mongorestore`` program:
- :option:`--restoreDbUsersAndRoles`
- :option:`--oplogReplay <mongorestore --oplogReplay>`
- :option:`--preserveUUID <mongorestore --preserveUUID>`
.. include:: /includes/fact-target-cluster-rollbacks.rst
.. _mongorestore-required-access:
Required Access
---------------
To restore data to a MongoDB deployment that has :manual:`access control
</core/authorization>` enabled, the :authrole:`restore` role provides
the necessary privileges to restore data from backups *if* the data does
not include :data:`system.profile <<database>.system.profile>`
collection data and you run ``mongorestore`` without the
:option:`--oplogReplay <mongorestore --oplogReplay>` option.
If the backup data includes :data:`system.profile
<<database>.system.profile>` collection data or you run
``mongorestore`` with the
:option:`--oplogReplay <mongorestore --oplogReplay>` option, you need
additional privileges:
.. list-table::
:widths: 20 80
* - ``system.profile``
- If the backup data includes :data:`system.profile
<<database>.system.profile>` collection data and the target
database does not contain the :data:`system.profile
<<database>.system.profile>` collection,
``mongorestore`` attempts to create the collection
even though the program does not actually restore
``system.profile`` documents. As such, the user requires
additional privileges to perform
:authaction:`createCollection` and
:authaction:`convertToCapped` actions on the
:data:`system.profile <<database>.system.profile>`
collection for a database.
Both the built-in roles :authrole:`dbAdmin` and
:authrole:`dbAdminAnyDatabase` provide the additional
privileges.
* - ``--oplogReplay``
- To run with :option:`--oplogReplay <mongorestore
--oplogReplay>`, create a :ref:`user-defined role
<create-user-defined-role>` that has :authaction:`anyAction`
on :ref:`resource-anyresource`.
Grant only to users who must run :binary:`mongorestore`
with :option:`--oplogReplay <mongorestore --oplogReplay>`.
Usage in Backup Strategy
------------------------
Standalones/Replica Sets
~~~~~~~~~~~~~~~~~~~~~~~~
For an overview of ``mongorestore`` usage as part of a
backup and recovery strategy, see
:manual:`Back Up and Restore with MongoDB Tools</tutorial/backup-and-restore-tools>`.
Sharded Clusters
~~~~~~~~~~~~~~~~
.. include:: /includes/extracts/sharded-clusters-backup-restore-mongodump-mongorestore-restriction.rst
Learn More
----------
- :ref:`mongorestore`
- :ref:`mongorestore-compatibility-and-installation`
- :ref:`mongorestore-examples`