2
2
Backup and Restoration Strategies
3
3
=================================
4
4
5
+ TODO: consistent use of LVM, lvm and where it's linked or not needs to
6
+ be addressed.
7
+
5
8
.. default-domain :: mongodb
6
9
7
10
This document provides an inventory of database backup strategies for
@@ -13,6 +16,9 @@ use the examples from the :ref:`block level backup methods
13
16
mongodump <database-dumps>`" sections to implement the backup
14
17
solution that is best suited to your deployment's needs.
15
18
19
+ TODO: why are some links in quotes and some not? (see: backups using mongodump
20
+ vs. block level...)
21
+
16
22
.. note ::
17
23
18
24
:term: `Replica sets <replica set> ` and :term: `shard clusters <shard
@@ -33,21 +39,21 @@ Overview
33
39
If you are familiar with backups systems in the context of database
34
40
systems please skip ahead to :ref: `backup considerations <backup-considerations >`.
35
41
36
- With MongoDB, the best way to are two major approaches to backups:
42
+ With MongoDB, there are two major approaches to backups:
37
43
using system-level tools, like disk image snapshots, and using various
38
- capacities present in the :ref: `mongodump tool <database-dumps >`
39
- to provide backup functionality. The underlying goal of these
40
- strategies is to produce a full copy of the data that you can use to
41
- bring up a new or replacement database instance.
44
+ capacities present in the :ref: `mongodump tool <database-dumps >`.
45
+ The underlying goal of these strategies is to produce a full and consistent
46
+ copy of the data that you can use to bring up a new or replacement
47
+ database instance.
42
48
43
49
The methods described in this document operate by copying the data
44
- file on the disk level. If your system does not provide a capacity for
50
+ file on the disk level. If your system does not provide functionality for
45
51
this kind of backup, see the section on :ref: `using database dumps for
46
52
backups <database-dumps>`" for more information.
47
53
48
- One of the leading challenges for producing reliable backups from
49
- database systems is ensuring that the state captured backup methods is
50
- in a consistent and steerable state. Because every environment is
54
+ One of the primary challenges for producing reliable backups of
55
+ database systems is ensuring that the state captured during backup is
56
+ in a consistent and usable???? state. Because every environment is
51
57
unique it's important to regularly test the backups that you capture
52
58
to ensure that your backup system is practically, and not just
53
59
theoretically, functional.
@@ -62,10 +68,10 @@ factors:
62
68
63
69
- Geography. Ensure that you move some backups away from the your
64
70
primary database infrastructure. It's important to be able to
65
- restore your database if you loose access to a system or site.
71
+ restore your database if you lose access to a system or site.
66
72
67
73
- System errors. Ensure that your backups can survive situations where
68
- hardware failures, disk errors, may impact the integrity or
74
+ hardware failures, disk errors, or ???? may impact the integrity or
69
75
availability of your backups.
70
76
71
77
- Production constraints. Backup operations themselves sometimes
@@ -74,11 +80,11 @@ factors:
74
80
windows.
75
81
76
82
- System capabilities. In order to use some of the block-level
77
- snapshot tools require special support on the operating-system or
83
+ snapshot tools requires special support on the operating-system or
78
84
infrastructure level.
79
85
80
86
- Database configuration. Cluster configuration including replication
81
- and sharding can affect the procured , timing, and impact of the
87
+ and sharding can affect the process??? , timing, and impact of the
82
88
backup process.
83
89
84
90
- Actual requirements. You may be able to save time, effort, and space
@@ -88,12 +94,12 @@ factors:
88
94
With this information in hand you can begin to develop a backup plan
89
95
for your database. Remember that all backup plans must be:
90
96
91
- - tested . If you cannot effectively restore your database from the
97
+ - Tested . If you cannot effectively restore your database from the
92
98
backup, then your backups are useless. Test backup restoration
93
99
regularly in practical situations to ensure that your backup system
94
100
provides value.
95
101
96
- - automated . Database backups need to run regularly and
102
+ - Automated . Database backups need to run regularly and
97
103
automatically. Also automate tests of backup restoration.
98
104
99
105
.. _block-level-backup :
@@ -105,15 +111,15 @@ This section will provides an overview of using disk/block level
105
111
snapshots (i.e. :term: `LVM ` or storage appliance) to backup a MongoDB
106
112
instance. These tools make a quick block-level backup of the device
107
113
that holds MongoDB's data files. These methods complete quickly, work
108
- reliably, and typically provide the easiest backup systems methods to
114
+ reliably, and typically provide the easiest backup systems method to
109
115
implement.
110
116
111
117
Snapshots typically work by creating pointers between the live data
112
- and a special snapshot data, you can think about these as "hard
113
- links." Then, as the working data diverges from the snapshot, the
118
+ and a special snapshot data partition??? , you can think about these as "hard
119
+ links." Then, as the working data diverges from the snapshot, these
114
120
systems use a copy-on-write strategy. As a result the snapshot only
115
121
stores modified data. After making the snapshot, you will mount the
116
- snapshot image and copy the files off disk image. The resulting backup
122
+ snapshot image and copy the files off the???? disk image. The resulting backup
117
123
contains full copies of all the data.
118
124
119
125
Snapshots have the following limitations:
@@ -122,9 +128,13 @@ Snapshots have the following limitations:
122
128
snapshot takes place. With journaling all states are recoverable,
123
129
without journaling you must flush all pending writes to disk.
124
130
131
+ TODO Might should explain this in more detail. Esp that snapshot with
132
+ journal needs journal to be on same volume as data, which in itself
133
+ has tradeoffs.... Often confuses people
134
+
125
135
- Snapshots create an image of an entire disk image. Unless you need
126
136
to back up your entire system, consider isolating your MongoDB data
127
- files, journal (if applicable,) and configuration on one logical
137
+ files, journal (if applicable), and configuration on one logical
128
138
disk that doesn't contain any other data.
129
139
130
140
Alternately, store all MongoDB data files on a dedicated device to
@@ -138,10 +148,12 @@ Snapshots have the following limitations:
138
148
With Journaling
139
149
~~~~~~~~~~~~~~~
140
150
141
- If your system has a snapshot capability and :program: `mongod ` instance
151
+ If your system has snapshot capability and your :program: `mongod ` instance
142
152
has journaling enabled then you can use any kind of file system or
143
153
volume/block level snapshot tool to create backups.
144
154
155
+ TODO: do you need the note and the warning? Just warning?
156
+
145
157
.. note ::
146
158
147
159
Journaling is not enabled by default on systems running with 32-bit
@@ -150,11 +162,13 @@ volume/block level snapshot tool to create backups.
150
162
.. warning ::
151
163
152
164
MongoDB disables journaling on 32 bit systems and all pre-1.9.2
153
- 64-bit versions. Specify the ":setting: `journal ` = ``true ``" in the
165
+ 64-bit versions. Specify ":setting: `journal ` = ``true ``" in the
154
166
configuration or use the :option: `--journal <mongod --journal> `
155
167
run-time option for :program: `mongod ` to ensure that MongoDB uses
156
168
journaling.
157
169
170
+ TODO: I don't quite understand the wording in this block
171
+
158
172
Many service providers provide a block-level backup service based on
159
173
disk image snapshots. If you manage your own infrastructure on a
160
174
Linux-based system, configure your system with :term: `LVM ` to provide
@@ -168,6 +182,7 @@ LVM-based setups *within* a cloud/virtualized environment.
168
182
169
183
If you use Amazon's EBS service in a software RAID 10 (e.g. 1+0)
170
184
configuration, use LVM to capture a consistent disk image.
185
+ TODO: link to Amazon section in this file
171
186
172
187
The following sections provide an overview of a simple backup process
173
188
using LVM on a Linux system. While the tools, commands, and paths may
@@ -186,7 +201,7 @@ following format:
186
201
187
202
lvcreate --size 100M --snapshot --name mdb-snap01 /dev/vg0/mongodb
188
203
189
- This command creates a lvm snapshot (with the "``--snapshot `` option)
204
+ This command creates an LVM snapshot (with the "``--snapshot `` option)
190
205
named "``mdb-snap01 ``" of the "``mongodb ``" volume in the "``vg0 ``"
191
206
volume group.
192
207
@@ -204,13 +219,13 @@ current state of ``/dev/vg0/mongodb`` and the creation of the snapshot
204
219
.. warning ::
205
220
206
221
Ensure that you create snapshots with enough space to account for
207
- data growth, particularly for a period of that it takes to copy to
222
+ data growth, particularly for the period of time that it takes to copy
208
223
data out of the system or to a temporary image.
209
224
210
225
If you your snapshot runs out of space, the snapshot image
211
- becomes unusable. You discard this LVM and create another.
226
+ becomes unusable. Discard this LVM and create another.
212
227
213
- The snapshot exists when the command returns. You can restore
228
+ The snapshot has been created when the command returns. You can restore
214
229
directly from the snapshot at any time or by creating a new logical
215
230
volume and restoring from this snapshot to the alternate image.
216
231
@@ -223,8 +238,8 @@ that you archive these snapshots and store them elsewhere.
223
238
Archive Snapshots
224
239
`````````````````
225
240
226
- After creating a snapshot, mount the snapshot and move the data to a
227
- separate storage You. system may wish to compress the backup images as
241
+ After creating a snapshot, mount the snapshot and move the data to
242
+ separate storage. Your system may wish to compress the backup images as
228
243
you move the offline. Consider the following procedure to fully
229
244
archive the data from the snapshot:
230
245
@@ -282,8 +297,8 @@ This sequence:
282
297
283
298
.. _backup-restore-from-snapshot :
284
299
285
- Restore Directly from a Snapshots
286
- `````````````````````````````````
300
+ Restore Directly from a Snapshot
301
+ ````````````````````````````````
287
302
288
303
To combine the above processes without writing to a compressed ``tar ``
289
304
archive, use the following sequence:
@@ -311,7 +326,7 @@ procedure:
311
326
mount /dev/vg0/mdb-new /srv/mongodb
312
327
313
328
This sequence is identical to procedures explained above except that
314
- the output direct input (i.e. :term: `piped <pipe> `) over SSH to the
329
+ the output direct input ???? (i.e. :term: `piped <pipe> `) over SSH to the
315
330
remote system.
316
331
317
332
.. _backup-without-journaling :
@@ -320,10 +335,15 @@ Without Journaling
320
335
~~~~~~~~~~~~~~~~~~
321
336
322
337
If your :program: `mongod ` instance does not run with journaling
323
- enabled, obtaining a functional backup of a consistent state is more
338
+ enabled (OR if your journal is on a separate volume), obtaining a
339
+ functional backup of a consistent state is more
324
340
complicated. Flush all writes to disk and lock the database to prevent
325
341
writes during the backup process.
326
342
343
+ TODO: Need to recommend that this is done on a secondary which is not
344
+ currently receiving reads, e.g., hidden secondary. Need to specify
345
+ what db.fsyncLock() does and link.
346
+
327
347
To flush writes and lock the database before performing the snapshot,
328
348
issue the following command:
329
349
@@ -342,7 +362,8 @@ completed, issue the following command:
342
362
.. note ::
343
363
344
364
Version 1.9.0 added :func: `db.fsyncLock() ` and
345
- :func: `db.fsyncUnlock() ` helpers to the :program: `mongo ` shell.
365
+ :func: `db.fsyncUnlock() ` helpers to the :program: `mongo ` shell. Prior to this
366
+ version, use the following commands:
346
367
347
368
.. code-block :: javascript
348
369
0 commit comments