2 Copyright 2015 John Snow <jsnow@redhat.com> and Red Hat, Inc.
5 This file is licensed via The FreeBSD Documentation License, the full text of
6 which is included at the end of this document.
9 # Dirty Bitmaps and Incremental Backup
11 * Dirty Bitmaps are objects that track which data needs to be backed up for the
12 next incremental backup.
14 * Dirty bitmaps can be created at any time and attached to any node
15 (not just complete drives.)
19 * A dirty bitmap's name is unique to the node, but bitmaps attached to different
20 nodes can share the same name.
24 * A Bitmap can be "frozen," which means that it is currently in-use by a backup
25 operation and cannot be deleted, renamed, written to, reset,
30 ### Supported Commands ###
32 * block-dirty-bitmap-add
33 * block-dirty-bitmap-remove
34 * block-dirty-bitmap-clear
38 * To create a new bitmap, enabled, on the drive with id=drive0:
41 { "execute": "block-dirty-bitmap-add",
49 * This bitmap will have a default granularity that matches the cluster size of
50 its associated drive, if available, clamped to between [4KiB, 64KiB].
51 The current default for qcow2 is 64KiB.
53 * To create a new bitmap that tracks changes in 32KiB segments:
56 { "execute": "block-dirty-bitmap-add",
67 * Bitmaps that are frozen cannot be deleted.
69 * Deleting the bitmap does not impact any other bitmaps attached to the same
70 node, nor does it affect any backups already created from this node.
72 * Because bitmaps are only unique to the node to which they are attached,
73 you must specify the node/drive name here, too.
76 { "execute": "block-dirty-bitmap-remove",
86 * Resetting a bitmap will clear all information it holds.
88 * An incremental backup created from an empty bitmap will copy no data,
89 as if nothing has changed.
92 { "execute": "block-dirty-bitmap-clear",
100 ## Transactions (Not yet implemented)
102 * Transactional commands are forthcoming in a future version,
103 and are not yet available for use. This section serves as
104 documentation of intent for their design and usage.
108 Bitmaps can be safely modified when the VM is paused or halted by using
109 the basic QMP commands. For instance, you might perform the following actions:
111 1. Boot the VM in a paused state.
112 2. Create a full drive backup of drive0.
113 3. Create a new bitmap attached to drive0.
114 4. Resume execution of the VM.
115 5. Incremental backups are ready to be created.
117 At this point, the bitmap and drive backup would be correctly in sync,
118 and incremental backups made from this point forward would be correctly aligned
119 to the full drive backup.
121 This is not particularly useful if we decide we want to start incremental
122 backups after the VM has been running for a while, for which we will need to
123 perform actions such as the following:
125 1. Boot the VM and begin execution.
126 2. Using a single transaction, perform the following operations:
128 * Create a full drive backup of drive0.
129 3. Incremental backups are now ready to be created.
131 ### Supported Bitmap Transactions
133 * block-dirty-bitmap-add
134 * block-dirty-bitmap-clear
136 The usages are identical to their respective QMP commands, but see below
139 ### Example: New Incremental Backup
141 As outlined in the justification, perhaps we want to create a new incremental
142 backup chain attached to a drive.
145 { "execute": "transaction",
148 {"type": "block-dirty-bitmap-add",
149 "data": {"node": "drive0", "name": "bitmap0"} },
150 {"type": "drive-backup",
151 "data": {"device": "drive0", "target": "/path/to/full_backup.img",
152 "sync": "full", "format": "qcow2"} }
158 ### Example: New Incremental Backup Anchor Point
160 Maybe we just want to create a new full backup with an existing bitmap and
161 want to reset the bitmap to track the new chain.
164 { "execute": "transaction",
167 {"type": "block-dirty-bitmap-clear",
168 "data": {"node": "drive0", "name": "bitmap0"} },
169 {"type": "drive-backup",
170 "data": {"device": "drive0", "target": "/path/to/new_full_backup.img",
171 "sync": "full", "format": "qcow2"} }
177 ## Incremental Backups
179 The star of the show.
181 **Nota Bene!** Only incremental backups of entire drives are supported for now.
182 So despite the fact that you can attach a bitmap to any arbitrary node, they are
183 only currently useful when attached to the root node. This is because
184 drive-backup only supports drives/devices instead of arbitrary nodes.
186 ### Example: First Incremental Backup
188 1. Create a full backup and sync it to the dirty bitmap, as in the transactional
189 examples above; or with the VM offline, manually create a full copy and then
190 create a new bitmap before the VM begins execution.
192 * Let's assume the full backup is named 'full_backup.img'.
193 * Let's assume the bitmap you created is 'bitmap0' attached to 'drive0'.
195 2. Create a destination image for the incremental backup that utilizes the
196 full backup as a backing image.
198 * Let's assume it is named 'incremental.0.img'.
201 # qemu-img create -f qcow2 incremental.0.img -b full_backup.img -F qcow2
204 3. Issue the incremental backup command:
207 { "execute": "drive-backup",
211 "target": "incremental.0.img",
213 "sync": "dirty-bitmap",
219 ### Example: Second Incremental Backup
221 1. Create a new destination image for the incremental backup that points to the
222 previous one, e.g.: 'incremental.1.img'
225 # qemu-img create -f qcow2 incremental.1.img -b incremental.0.img -F qcow2
228 2. Issue a new incremental backup command. The only difference here is that we
229 have changed the target image below.
232 { "execute": "drive-backup",
236 "target": "incremental.1.img",
238 "sync": "dirty-bitmap",
246 * In the event of an error that occurs after a backup job is successfully
247 launched, either by a direct QMP command or a QMP transaction, the user
248 will receive a BLOCK_JOB_COMPLETE event with a failure message, accompanied
249 by a BLOCK_JOB_ERROR event.
251 * In the case of an event being cancelled, the user will receive a
252 BLOCK_JOB_CANCELLED event instead of a pair of COMPLETE and ERROR events.
254 * In either case, the incremental backup data contained within the bitmap is
255 safely rolled back, and the data within the bitmap is not lost. The image
256 file created for the failed attempt can be safely deleted.
258 * Once the underlying problem is fixed (e.g. more storage space is freed up),
259 you can simply retry the incremental backup command with the same bitmap.
263 1. Create a target image:
266 # qemu-img create -f qcow2 incremental.0.img -b full_backup.img -F qcow2
269 2. Attempt to create an incremental backup via QMP:
272 { "execute": "drive-backup",
276 "target": "incremental.0.img",
278 "sync": "dirty-bitmap",
284 3. Receive an event notifying us of failure:
287 { "timestamp": { "seconds": 1424709442, "microseconds": 844524 },
288 "data": { "speed": 0, "offset": 0, "len": 67108864,
289 "error": "No space left on device",
290 "device": "drive1", "type": "backup" },
291 "event": "BLOCK_JOB_COMPLETED" }
294 4. Delete the failed incremental, and re-create the image.
297 # rm incremental.0.img
298 # qemu-img create -f qcow2 incremental.0.img -b full_backup.img -F qcow2
301 5. Retry the command after fixing the underlying problem,
302 such as freeing up space on the backup volume:
305 { "execute": "drive-backup",
309 "target": "incremental.0.img",
311 "sync": "dirty-bitmap",
317 6. Receive confirmation that the job completed successfully:
320 { "timestamp": { "seconds": 1424709668, "microseconds": 526525 },
321 "data": { "device": "drive1", "type": "backup",
322 "speed": 0, "len": 67108864, "offset": 67108864},
323 "event": "BLOCK_JOB_COMPLETED" }
327 The FreeBSD Documentation License
329 Redistribution and use in source (Markdown) and 'compiled' forms (SGML, HTML,
330 PDF, PostScript, RTF and so forth) with or without modification, are permitted
331 provided that the following conditions are met:
333 Redistributions of source code (Markdown) must retain the above copyright
334 notice, this list of conditions and the following disclaimer of this file
337 Redistributions in compiled form (transformed to other DTDs, converted to PDF,
338 PostScript, RTF and other formats) must reproduce the above copyright notice,
339 this list of conditions and the following disclaimer in the documentation and/or
340 other materials provided with the distribution.
342 THIS DOCUMENTATION IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
343 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
344 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
345 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
346 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
347 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
348 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
349 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
350 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
351 THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.