check.rst.inc 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. | **options** |
  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. | | ``--find-lost-archives`` | attempt to find lost archives |
  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 archives matching all patterns. see "borg help match-archives". |
  31. +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  32. | | ``--sort-by KEYS`` | Comma-separated list of sorting keys; valid keys are: timestamp, archive, name, id, tags, host, user; 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. options
  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. --find-lost-archives attempt to find lost archives
  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 archives matching all patterns. see "borg help match-archives".
  64. --sort-by KEYS Comma-separated list of sorting keys; valid keys are: timestamp, archive, name, id, tags, host, user; 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 ssh:// remote repository, please note that the checks run on
  81. the 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 scan for archives whose
  87. entries were lost from the archive directory, pass ``--find-lost-archives``.
  88. It requires reading all data and is hence very time consuming.
  89. To additionally cryptographically verify the file (content) data integrity,
  90. pass ``--verify-data``, which is even more time consuming.
  91. When checking archives of a remote repository, archive checks run on the client
  92. machine because they require decrypting data and therefore the encryption key.
  93. Both steps can also be run independently. Pass ``--repository-only`` to run the
  94. repository checks only, or pass ``--archives-only`` to run the archive checks
  95. only.
  96. The ``--max-duration`` option can be used to split a long-running repository
  97. check into multiple partial checks. After the given number of seconds the check
  98. is interrupted. The next partial check will continue where the previous one
  99. stopped, until the full repository has been checked. Assuming a complete check
  100. would take 7 hours, then running a daily check with ``--max-duration=3600``
  101. (1 hour) would result in one full repository check per week. Doing a full
  102. repository check aborts any previous partial check; the next partial check will
  103. restart from the beginning. With partial repository checks you can run neither
  104. archive checks, nor enable repair mode. Consequently, if you want to use
  105. ``--max-duration`` you must also pass ``--repository-only``, and must not pass
  106. ``--archives-only``, nor ``--repair``.
  107. **Warning:** Please note that partial repository checks (i.e. running it with
  108. ``--max-duration``) can only perform non-cryptographic checksum checks on the
  109. repository files. Enabling partial repository checks excepts archive checks
  110. for the same reason. Therefore partial checks may be useful with very large
  111. repositories only where a full check would take too long.
  112. The ``--verify-data`` option will perform a full integrity verification (as
  113. opposed to checking just the xxh64) of data, which means reading the
  114. data from the repository, decrypting and decompressing it. It is a complete
  115. cryptographic verification and hence very time consuming, but will detect any
  116. accidental and malicious corruption. Tamper-resistance is only guaranteed for
  117. encrypted repositories against attackers without access to the keys. You can
  118. not use ``--verify-data`` with ``--repository-only``.
  119. The ``--find-lost-archives`` option will also scan the whole repository, but
  120. tells Borg to search for lost archive metadata. If Borg encounters any archive
  121. metadata that doesn't match with an archive directory entry (including
  122. soft-deleted archives), it means that an entry was lost.
  123. Unless ``borg compact`` is called, these archives can be fully restored with
  124. ``--repair``. Please note that ``--find-lost-archives`` must read a lot of
  125. data from the repository and is thus very time consuming. You can not use
  126. ``--find-lost-archives`` with ``--repository-only``.
  127. About repair mode
  128. +++++++++++++++++
  129. The check command is a readonly task by default. If any corruption is found,
  130. Borg will report the issue and proceed with checking. To actually repair the
  131. issues found, pass ``--repair``.
  132. .. note::
  133. ``--repair`` is a **POTENTIALLY DANGEROUS FEATURE** and might lead to data
  134. loss! This does not just include data that was previously lost anyway, but
  135. might include more data for kinds of corruption it is not capable of
  136. dealing with. **BE VERY CAREFUL!**
  137. Pursuant to the previous warning it is also highly recommended to test the
  138. reliability of the hardware running Borg with stress testing software. This
  139. especially includes storage and memory testers. Unreliable hardware might lead
  140. to additional data loss.
  141. It is highly recommended to create a backup of your repository before running
  142. in repair mode (i.e. running it with ``--repair``).
  143. Repair mode will attempt to fix any corruptions found. Fixing corruptions does
  144. not mean recovering lost data: Borg can not magically restore data lost due to
  145. e.g. a hardware failure. Repairing a repository means sacrificing some data
  146. for the sake of the repository as a whole and the remaining data. Hence it is,
  147. by definition, a potentially lossy task.
  148. In practice, repair mode hooks into both the repository and archive checks:
  149. 1. When checking the repository's consistency, repair mode removes corrupted
  150. objects from the repository after it did a 2nd try to read them correctly.
  151. 2. When checking the consistency and correctness of archives, repair mode might
  152. remove whole archives from the manifest if their archive metadata chunk is
  153. corrupt or lost. Borg will also report files that reference missing chunks.
  154. If ``--repair --find-lost-archives`` is given, previously lost entries will
  155. be recreated in the archive directory. This is only possible before
  156. ``borg compact`` would remove the archives' data completely.