check.rst.inc 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. .. IMPORTANT: this file is auto-generated from borg's built-in help, do not edit!
  2. .. _borg_check:
  3. borg check
  4. ----------
  5. .. code-block:: none
  6. borg [common options] check [options]
  7. .. only:: html
  8. .. class:: borg-options-table
  9. +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+
  10. | **optional arguments** |
  11. +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+
  12. | | ``--repository-only`` | only perform repository checks |
  13. +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+
  14. | | ``--archives-only`` | only perform archives checks |
  15. +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+
  16. | | ``--verify-data`` | perform cryptographic archive data integrity verification (conflicts with ``--repository-only``) |
  17. +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+
  18. | | ``--repair`` | attempt to repair any inconsistencies found |
  19. +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+
  20. | | ``--undelete-archives`` | attempt to undelete archives (use with --repair) |
  21. +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+
  22. | | ``--max-duration SECONDS`` | do only a partial repo check for max. SECONDS seconds (Default: unlimited) |
  23. +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+
  24. | .. class:: borg-common-opt-ref |
  25. | |
  26. | :ref:`common_options` |
  27. +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+
  28. | **Archive filters** — Archive filters can be applied to repository targets. |
  29. +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+
  30. | | ``-a PATTERN``, ``--match-archives PATTERN`` | only consider archive names matching the pattern. see "borg help match-archives". |
  31. +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+
  32. | | ``--sort-by KEYS`` | Comma-separated list of sorting keys; valid keys are: timestamp, archive, name, id; default is: timestamp |
  33. +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+
  34. | | ``--first N`` | consider first N archives after other filters were applied |
  35. +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+
  36. | | ``--last N`` | consider last N archives after other filters were applied |
  37. +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+
  38. | | ``--oldest TIMESPAN`` | consider archives between the oldest archive's timestamp and (oldest + TIMESPAN), e.g. 7d or 12m. |
  39. +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+
  40. | | ``--newest TIMESPAN`` | consider archives between the newest archive's timestamp and (newest - TIMESPAN), e.g. 7d or 12m. |
  41. +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+
  42. | | ``--older TIMESPAN`` | consider archives older than (now - TIMESPAN), e.g. 7d or 12m. |
  43. +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+
  44. | | ``--newer TIMESPAN`` | consider archives newer than (now - TIMESPAN), e.g. 7d or 12m. |
  45. +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+
  46. .. raw:: html
  47. <script type='text/javascript'>
  48. $(document).ready(function () {
  49. $('.borg-options-table colgroup').remove();
  50. })
  51. </script>
  52. .. only:: latex
  53. optional arguments
  54. --repository-only only perform repository checks
  55. --archives-only only perform archives checks
  56. --verify-data perform cryptographic archive data integrity verification (conflicts with ``--repository-only``)
  57. --repair attempt to repair any inconsistencies found
  58. --undelete-archives attempt to undelete archives (use with --repair)
  59. --max-duration SECONDS do only a partial repo check for max. SECONDS seconds (Default: unlimited)
  60. :ref:`common_options`
  61. |
  62. Archive filters
  63. -a PATTERN, --match-archives PATTERN only consider archive names matching the pattern. see "borg help match-archives".
  64. --sort-by KEYS Comma-separated list of sorting keys; valid keys are: timestamp, archive, name, id; default is: timestamp
  65. --first N consider first N archives after other filters were applied
  66. --last N consider last N archives after other filters were applied
  67. --oldest TIMESPAN consider archives between the oldest archive's timestamp and (oldest + TIMESPAN), e.g. 7d or 12m.
  68. --newest TIMESPAN consider archives between the newest archive's timestamp and (newest - TIMESPAN), e.g. 7d or 12m.
  69. --older TIMESPAN consider archives older than (now - TIMESPAN), e.g. 7d or 12m.
  70. --newer TIMESPAN consider archives newer than (now - TIMESPAN), e.g. 7d or 12m.
  71. Description
  72. ~~~~~~~~~~~
  73. The check command verifies the consistency of a repository and its archives.
  74. It consists of two major steps:
  75. 1. Checking the consistency of the repository itself. This includes checking
  76. the file magic headers, and both the metadata and data of all objects in
  77. the repository. The read data is checked by size and hash. Bit rot and other
  78. types of accidental damage can be detected this way. Running the repository
  79. check can be split into multiple partial checks using ``--max-duration``.
  80. When checking a remote repository, please note that the checks run on the
  81. server and do not cause significant network traffic.
  82. 2. Checking consistency and correctness of the archive metadata and optionally
  83. archive data (requires ``--verify-data``). This includes ensuring that the
  84. repository manifest exists, the archive metadata chunk is present, and that
  85. all chunks referencing files (items) in the archive exist. This requires
  86. reading archive and file metadata, but not data. To cryptographically verify
  87. the file (content) data integrity pass ``--verify-data``, but keep in mind
  88. that this requires reading all data and is hence very time consuming. When
  89. checking archives of a remote repository, archive checks run on the client
  90. machine because they require decrypting data and therefore the encryption
  91. key.
  92. Both steps can also be run independently. Pass ``--repository-only`` to run the
  93. repository checks only, or pass ``--archives-only`` to run the archive checks
  94. only.
  95. The ``--max-duration`` option can be used to split a long-running repository
  96. check into multiple partial checks. After the given number of seconds the check
  97. is interrupted. The next partial check will continue where the previous one
  98. stopped, until the full repository has been checked. Assuming a complete check
  99. would take 7 hours, then running a daily check with ``--max-duration=3600``
  100. (1 hour) would result in one full repository check per week. Doing a full
  101. repository check aborts any previous partial check; the next partial check will
  102. restart from the beginning. With partial repository checks you can run neither
  103. archive checks, nor enable repair mode. Consequently, if you want to use
  104. ``--max-duration`` you must also pass ``--repository-only``, and must not pass
  105. ``--archives-only``, nor ``--repair``.
  106. **Warning:** Please note that partial repository checks (i.e. running it with
  107. ``--max-duration``) can only perform non-cryptographic checksum checks on the
  108. repository files. Enabling partial repository checks excepts archive checks
  109. for the same reason. Therefore partial checks may be useful with very large
  110. repositories only where a full check would take too long.
  111. The ``--verify-data`` option will perform a full integrity verification (as
  112. opposed to checking just the xxh64) of data, which means reading the
  113. data from the repository, decrypting and decompressing it. It is a complete
  114. cryptographic verification and hence very time consuming, but will detect any
  115. accidental and malicious corruption. Tamper-resistance is only guaranteed for
  116. encrypted repositories against attackers without access to the keys. You can
  117. not use ``--verify-data`` with ``--repository-only``.
  118. About repair mode
  119. +++++++++++++++++
  120. The check command is a readonly task by default. If any corruption is found,
  121. Borg will report the issue and proceed with checking. To actually repair the
  122. issues found, pass ``--repair``.
  123. .. note::
  124. ``--repair`` is a **POTENTIALLY DANGEROUS FEATURE** and might lead to data
  125. loss! This does not just include data that was previously lost anyway, but
  126. might include more data for kinds of corruption it is not capable of
  127. dealing with. **BE VERY CAREFUL!**
  128. Pursuant to the previous warning it is also highly recommended to test the
  129. reliability of the hardware running Borg with stress testing software. This
  130. especially includes storage and memory testers. Unreliable hardware might lead
  131. to additional data loss.
  132. It is highly recommended to create a backup of your repository before running
  133. in repair mode (i.e. running it with ``--repair``).
  134. Repair mode will attempt to fix any corruptions found. Fixing corruptions does
  135. not mean recovering lost data: Borg can not magically restore data lost due to
  136. e.g. a hardware failure. Repairing a repository means sacrificing some data
  137. for the sake of the repository as a whole and the remaining data. Hence it is,
  138. by definition, a potentially lossy task.
  139. In practice, repair mode hooks into both the repository and archive checks:
  140. 1. When checking the repository's consistency, repair mode removes corrupted
  141. objects from the repository after it did a 2nd try to read them correctly.
  142. 2. When checking the consistency and correctness of archives, repair mode might
  143. remove whole archives from the manifest if their archive metadata chunk is
  144. corrupt or lost. On a chunk level (i.e. the contents of files), repair mode
  145. will replace corrupt or lost chunks with a same-size replacement chunk of
  146. zeroes. If a previously zeroed chunk reappears, repair mode will restore
  147. this lost chunk using the new chunk.
  148. Most steps taken by repair mode have a one-time effect on the repository, like
  149. removing a lost archive from the repository. However, replacing a corrupt or
  150. lost chunk with an all-zero replacement will have an ongoing effect on the
  151. repository: When attempting to extract a file referencing an all-zero chunk,
  152. the ``extract`` command will distinctly warn about it. The FUSE filesystem
  153. created by the ``mount`` command will reject reading such a "zero-patched"
  154. file unless a special mount option is given.
  155. As mentioned earlier, Borg might be able to "heal" a "zero-patched" file in
  156. repair mode, if all its previously lost chunks reappear (e.g. via a later
  157. backup). This is achieved by Borg not only keeping track of the all-zero
  158. replacement chunks, but also by keeping metadata about the lost chunks. In
  159. repair mode Borg will check whether a previously lost chunk reappeared and will
  160. replace the all-zero replacement chunk by the reappeared chunk. If all lost
  161. chunks of a "zero-patched" file reappear, this effectively "heals" the file.
  162. Consequently, if lost chunks were repaired earlier, it is advised to run
  163. ``--repair`` a second time after creating some new backups.
  164. If ``--repair --undelete-archives`` is given, Borg will scan the repository
  165. for archive metadata and if it finds some where no corresponding archives
  166. directory entry exists, it will create the entries. This is basically undoing
  167. ``borg delete archive`` or ``borg prune ...`` commands and only possible before
  168. ``borg compact`` would remove the archives' data completely.