check.rst.inc 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. | | ``--save-space`` | work slower, but using less space |
  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. | | ``-P PREFIX``, ``--prefix PREFIX`` | only consider archive names starting with this prefix. |
  31. +-----------------------------------------------------------------------------+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | | ``-a GLOB``, ``--glob-archives GLOB`` | only consider archive names matching the glob. sh: rules apply, see "borg help patterns". ``--prefix`` and ``--glob-archives`` are mutually exclusive. |
  33. +-----------------------------------------------------------------------------+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | | ``--sort-by KEYS`` | Comma-separated list of sorting keys; valid keys are: timestamp, name, id; default is: timestamp |
  35. +-----------------------------------------------------------------------------+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | | ``--first N`` | consider first N archives after other filters were applied |
  37. +-----------------------------------------------------------------------------+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | | ``--last N`` | consider last N archives after other filters were applied |
  39. +-----------------------------------------------------------------------------+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. .. raw:: html
  41. <script type='text/javascript'>
  42. $(document).ready(function () {
  43. $('.borg-options-table colgroup').remove();
  44. })
  45. </script>
  46. .. only:: latex
  47. optional arguments
  48. --repository-only only perform repository checks
  49. --archives-only only perform archives checks
  50. --verify-data perform cryptographic archive data integrity verification (conflicts with ``--repository-only``)
  51. --repair attempt to repair any inconsistencies found
  52. --save-space work slower, but using less space
  53. --max-duration SECONDS do only a partial repo check for max. SECONDS seconds (Default: unlimited)
  54. :ref:`common_options`
  55. |
  56. Archive filters
  57. -P PREFIX, --prefix PREFIX only consider archive names starting with this prefix.
  58. -a GLOB, --glob-archives GLOB only consider archive names matching the glob. sh: rules apply, see "borg help patterns". ``--prefix`` and ``--glob-archives`` are mutually exclusive.
  59. --sort-by KEYS Comma-separated list of sorting keys; valid keys are: timestamp, name, id; default is: timestamp
  60. --first N consider first N archives after other filters were applied
  61. --last N consider last N archives after other filters were applied
  62. Description
  63. ~~~~~~~~~~~
  64. The check command verifies the consistency of a repository and the corresponding archives.
  65. check --repair is a potentially dangerous function and might lead to data loss
  66. (for kinds of corruption it is not capable of dealing with). BE VERY CAREFUL!
  67. Pursuant to the previous warning it is also highly recommended to test the
  68. reliability of the hardware running this software with stress testing software
  69. such as memory testers. Unreliable hardware can also lead to data loss especially
  70. when this command is run in repair mode.
  71. First, the underlying repository data files are checked:
  72. - For all segments, the segment magic header is checked.
  73. - For all objects stored in the segments, all metadata (e.g. CRC and size) and
  74. all data is read. The read data is checked by size and CRC. Bit rot and other
  75. types of accidental damage can be detected this way.
  76. - In repair mode, if an integrity error is detected in a segment, try to recover
  77. as many objects from the segment as possible.
  78. - In repair mode, make sure that the index is consistent with the data stored in
  79. the segments.
  80. - If checking a remote repo via ``ssh:``, the repo check is executed on the server
  81. without causing significant network traffic.
  82. - The repository check can be skipped using the ``--archives-only`` option.
  83. - A repository check can be time consuming. Partial checks are possible with the
  84. ``--max-duration`` option.
  85. Second, the consistency and correctness of the archive metadata is verified:
  86. - Is the repo manifest present? If not, it is rebuilt from archive metadata
  87. chunks (this requires reading and decrypting of all metadata and data).
  88. - Check if archive metadata chunk is present; if not, remove archive from manifest.
  89. - For all files (items) in the archive, for all chunks referenced by these
  90. files, check if chunk is present. In repair mode, if a chunk is not present,
  91. replace it with a same-size replacement chunk of zeroes. If a previously lost
  92. chunk reappears (e.g. via a later backup), in repair mode the all-zero replacement
  93. chunk will be replaced by the correct chunk. This requires reading of archive and
  94. file metadata, but not data.
  95. - In repair mode, when all the archives were checked, orphaned chunks are deleted
  96. from the repo. One cause of orphaned chunks are input file related errors (like
  97. read errors) in the archive creation process.
  98. - In verify-data mode, a complete cryptographic verification of the archive data
  99. integrity is performed. This conflicts with ``--repository-only`` as this mode
  100. only makes sense if the archive checks are enabled. The full details of this mode
  101. are documented below.
  102. - If checking a remote repo via ``ssh:``, the archive check is executed on the
  103. client machine because it requires decryption, and this is always done client-side
  104. as key access is needed.
  105. - The archive checks can be time consuming; they can be skipped using the
  106. ``--repository-only`` option.
  107. The ``--max-duration`` option can be used to split a long-running repository check
  108. into multiple partial checks. After the given number of seconds the check is
  109. interrupted. The next partial check will continue where the previous one stopped,
  110. until the complete repository has been checked. Example: Assuming a complete check took 7
  111. hours, then running a daily check with --max-duration=3600 (1 hour) resulted in one
  112. completed check per week.
  113. Attention: A partial --repository-only check can only do way less checking than a full
  114. --repository-only check: only the non-cryptographic checksum checks on segment file
  115. entries are done, while a full --repository-only check would also do a repo index check.
  116. A partial check cannot be combined with the ``--repair`` option. Partial checks
  117. may therefore be useful only with very large repositories where a full check would take
  118. too long.
  119. Doing a full repository check aborts a partial check; the next partial check will restart
  120. from the beginning.
  121. The ``--verify-data`` option will perform a full integrity verification (as opposed to
  122. checking the CRC32 of the segment) of data, which means reading the data from the
  123. repository, decrypting and decompressing it. This is a cryptographic verification,
  124. which will detect (accidental) corruption. For encrypted repositories it is
  125. tamper-resistant as well, unless the attacker has access to the keys. It is also very
  126. slow.