|
| 1 | +/*! @arch_page arch-backup Backup |
| 2 | + |
| 3 | +# Overview # |
| 4 | + |
| 5 | +Backup in WiredTiger can be performed using the \c "backup:" cursor. WiredTiger |
| 6 | +supports four types of backups. |
| 7 | + |
| 8 | +1. Full database |
| 9 | +2. Block-based incremental backup |
| 10 | +3. Log-based incremental backup |
| 11 | +4. Target backup |
| 12 | + |
| 13 | +The following page describes how backup works inside the WiredTiger. Please refer to |
| 14 | +@ref backup for details on how to use each of these types of backups. |
| 15 | + |
| 16 | +# Full database # |
| 17 | + |
| 18 | +When the application opens the backup cursor, internally WiredTiger generates a list of all |
| 19 | +files in the database that are necessary for the backup. WiredTiger takes both the checkpoint |
| 20 | +and schema locks to block database file modifications while generating the list files. There |
| 21 | +is a contract that all files that exist at the time the backup starts exist for the entire time |
| 22 | +the backup cursor is open. This contract applies to all files in the database, not just files |
| 23 | +that are included in the generated list. |
| 24 | + |
| 25 | +WiredTiger log files are also part of the generated file list for backup. There is a contract |
| 26 | +that the log files do not contain or make visible operations that are added to the log after |
| 27 | +the backup started that could have adverse affects during recovery and restore. Therefore |
| 28 | +WiredTiger forces a log file switch when opening the backup cursor. To fulfill the earlier |
| 29 | +contract that all files must exist during backup, WiredTiger does not use any pre-allocated |
| 30 | +log files nor does it archive or remove old log files during the time the backup cursor is open. |
| 31 | + |
| 32 | +Once the backup is opened successfully, any checkpoints that exist on the database before |
| 33 | +backup starts must be retained until the backup cursor is closed. All the newer checkpoints |
| 34 | +that are created during the backup in progress are cleaned whenever a newer checkpoint is |
| 35 | +created. |
| 36 | + |
| 37 | +# Block-based incremental backup # |
| 38 | + |
| 39 | +Block-based incremental backup is performed by tracking the modified blocks in the checkpoint. |
| 40 | +Whenever a new checkpoint occurs on a file, any new or modified blocks in this checkpoint are |
| 41 | +recorded as a bit string. This bit string information is updated with every new checkpoint. |
| 42 | + |
| 43 | +Whenever the incremental backup cursor is opened to perform the backup, WiredTiger returns all |
| 44 | +the file offsets and sizes that are modified from the previous source backup identifier. |
| 45 | +WiredTiger returns the full file information to be copied for all the new files that are created, |
| 46 | +renamed or imported into the database after the incremental backup cursor is opened. Refer to |
| 47 | +@ref backup_incremental-block for more information on how to use the block-based incremental backup. |
| 48 | + |
| 49 | +# Log-based incremental backup # |
| 50 | + |
| 51 | +When the backup cursor is opened with the \c target configuration string as \c "target=(\"log:\\")" |
| 52 | +the log-based incremental backup is performed by adding all the existing log files in the database |
| 53 | +to the list of files that needs to be copied. Applications wanting to use log files for incremental |
| 54 | +backup must first disable automatic log file removal using the \c log=(archive=false) configuration |
| 55 | +to ::wiredtiger_open. By default, WiredTiger automatically removes log files no longer required |
| 56 | +for recovery. Refer to @ref backup_incremental for more information on how to use the log-based |
| 57 | +incremental backup. |
| 58 | + |
| 59 | +# Target backup # |
| 60 | + |
| 61 | +When the backup cursor is opened with the \c target configuration string as \c "target=", |
| 62 | +WiredTiger internally generates a list of targeted files instead of all files like the full backup. |
| 63 | +If the targeted object is a table, all the indexes and column groups of the table are also backed up. |
| 64 | + |
| 65 | +Note: There can only be one backup cursor open at a time unless using duplicate backup |
| 66 | +cursors. The duplicate backup cursors are used for catching up with the log files or with |
| 67 | +block-based incremental backup. Please refer to @ref backup_duplicate for more details. |
| 68 | + |
| 69 | +*/ |
0 commit comments