borg-check.1 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. .\" Man page generated from reStructuredText.
  2. .
  3. .
  4. .nr rst2man-indent-level 0
  5. .
  6. .de1 rstReportMargin
  7. \\$1 \\n[an-margin]
  8. level \\n[rst2man-indent-level]
  9. level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
  10. -
  11. \\n[rst2man-indent0]
  12. \\n[rst2man-indent1]
  13. \\n[rst2man-indent2]
  14. ..
  15. .de1 INDENT
  16. .\" .rstReportMargin pre:
  17. . RS \\$1
  18. . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
  19. . nr rst2man-indent-level +1
  20. .\" .rstReportMargin post:
  21. ..
  22. .de UNINDENT
  23. . RE
  24. .\" indent \\n[an-margin]
  25. .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
  26. .nr rst2man-indent-level -1
  27. .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
  28. .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
  29. ..
  30. .TH "BORG-CHECK" 1 "2023-09-14" "" "borg backup tool"
  31. .SH NAME
  32. borg-check \- Check repository consistency
  33. .SH SYNOPSIS
  34. .sp
  35. borg [common options] check [options]
  36. .SH DESCRIPTION
  37. .sp
  38. The check command verifies the consistency of a repository and its archives.
  39. It consists of two major steps:
  40. .INDENT 0.0
  41. .IP 1. 3
  42. Checking the consistency of the repository itself. This includes checking
  43. the segment magic headers, and both the metadata and data of all objects in
  44. the segments. The read data is checked by size and CRC. Bit rot and other
  45. types of accidental damage can be detected this way. Running the repository
  46. check can be split into multiple partial checks using \fB\-\-max\-duration\fP\&.
  47. When checking a remote repository, please note that the checks run on the
  48. server and do not cause significant network traffic.
  49. .IP 2. 3
  50. Checking consistency and correctness of the archive metadata and optionally
  51. archive data (requires \fB\-\-verify\-data\fP). This includes ensuring that the
  52. repository manifest exists, the archive metadata chunk is present, and that
  53. all chunks referencing files (items) in the archive exist. This requires
  54. reading archive and file metadata, but not data. To cryptographically verify
  55. the file (content) data integrity pass \fB\-\-verify\-data\fP, but keep in mind
  56. that this requires reading all data and is hence very time consuming. When
  57. checking archives of a remote repository, archive checks run on the client
  58. machine because they require decrypting data and therefore the encryption
  59. key.
  60. .UNINDENT
  61. .sp
  62. Both steps can also be run independently. Pass \fB\-\-repository\-only\fP to run the
  63. repository checks only, or pass \fB\-\-archives\-only\fP to run the archive checks
  64. only.
  65. .sp
  66. The \fB\-\-max\-duration\fP option can be used to split a long\-running repository
  67. check into multiple partial checks. After the given number of seconds the check
  68. is interrupted. The next partial check will continue where the previous one
  69. stopped, until the full repository has been checked. Assuming a complete check
  70. would take 7 hours, then running a daily check with \fB\-\-max\-duration=3600\fP
  71. (1 hour) would result in one full repository check per week. Doing a full
  72. repository check aborts any previous partial check; the next partial check will
  73. restart from the beginning. With partial repository checks you can run neither
  74. archive checks, nor enable repair mode. Consequently, if you want to use
  75. \fB\-\-max\-duration\fP you must also pass \fB\-\-repository\-only\fP, and must not pass
  76. \fB\-\-archives\-only\fP, nor \fB\-\-repair\fP\&.
  77. .sp
  78. \fBWarning:\fP Please note that partial repository checks (i.e. running it with
  79. \fB\-\-max\-duration\fP) can only perform non\-cryptographic checksum checks on the
  80. segment files. A full repository check (i.e. without \fB\-\-max\-duration\fP) can
  81. also do a repository index check. Enabling partial repository checks excepts
  82. archive checks for the same reason. Therefore partial checks may be useful with
  83. very large repositories only where a full check would take too long.
  84. .sp
  85. The \fB\-\-verify\-data\fP option will perform a full integrity verification (as
  86. opposed to checking the CRC32 of the segment) of data, which means reading the
  87. data from the repository, decrypting and decompressing it. It is a complete
  88. cryptographic verification and hence very time consuming, but will detect any
  89. accidental and malicious corruption. Tamper\-resistance is only guaranteed for
  90. encrypted repositories against attackers without access to the keys. You can
  91. not use \fB\-\-verify\-data\fP with \fB\-\-repository\-only\fP\&.
  92. .SS About repair mode
  93. .sp
  94. The check command is a readonly task by default. If any corruption is found,
  95. Borg will report the issue and proceed with checking. To actually repair the
  96. issues found, pass \fB\-\-repair\fP\&.
  97. .sp
  98. \fBNOTE:\fP
  99. .INDENT 0.0
  100. .INDENT 3.5
  101. \fB\-\-repair\fP is a \fBPOTENTIALLY DANGEROUS FEATURE\fP and might lead to data
  102. loss! This does not just include data that was previously lost anyway, but
  103. might include more data for kinds of corruption it is not capable of
  104. dealing with. \fBBE VERY CAREFUL!\fP
  105. .UNINDENT
  106. .UNINDENT
  107. .sp
  108. Pursuant to the previous warning it is also highly recommended to test the
  109. reliability of the hardware running Borg with stress testing software. This
  110. especially includes storage and memory testers. Unreliable hardware might lead
  111. to additional data loss.
  112. .sp
  113. It is highly recommended to create a backup of your repository before running
  114. in repair mode (i.e. running it with \fB\-\-repair\fP).
  115. .sp
  116. Repair mode will attempt to fix any corruptions found. Fixing corruptions does
  117. not mean recovering lost data: Borg can not magically restore data lost due to
  118. e.g. a hardware failure. Repairing a repository means sacrificing some data
  119. for the sake of the repository as a whole and the remaining data. Hence it is,
  120. by definition, a potentially lossy task.
  121. .sp
  122. In practice, repair mode hooks into both the repository and archive checks:
  123. .INDENT 0.0
  124. .IP 1. 3
  125. When checking the repository\(aqs consistency, repair mode will try to recover
  126. as many objects from segments with integrity errors as possible, and ensure
  127. that the index is consistent with the data stored in the segments.
  128. .IP 2. 3
  129. When checking the consistency and correctness of archives, repair mode might
  130. remove whole archives from the manifest if their archive metadata chunk is
  131. corrupt or lost. On a chunk level (i.e. the contents of files), repair mode
  132. will replace corrupt or lost chunks with a same\-size replacement chunk of
  133. zeroes. If a previously zeroed chunk reappears, repair mode will restore
  134. this lost chunk using the new chunk. Lastly, repair mode will also delete
  135. orphaned chunks (e.g. caused by read errors while creating the archive).
  136. .UNINDENT
  137. .sp
  138. Most steps taken by repair mode have a one\-time effect on the repository, like
  139. removing a lost archive from the repository. However, replacing a corrupt or
  140. lost chunk with an all\-zero replacement will have an ongoing effect on the
  141. repository: When attempting to extract a file referencing an all\-zero chunk,
  142. the \fBextract\fP command will distinctly warn about it. The FUSE filesystem
  143. created by the \fBmount\fP command will reject reading such a \(dqzero\-patched\(dq
  144. file unless a special mount option is given.
  145. .sp
  146. As mentioned earlier, Borg might be able to \(dqheal\(dq a \(dqzero\-patched\(dq file in
  147. repair mode, if all its previously lost chunks reappear (e.g. via a later
  148. backup). This is achieved by Borg not only keeping track of the all\-zero
  149. replacement chunks, but also by keeping metadata about the lost chunks. In
  150. repair mode Borg will check whether a previously lost chunk reappeared and will
  151. replace the all\-zero replacement chunk by the reappeared chunk. If all lost
  152. chunks of a \(dqzero\-patched\(dq file reappear, this effectively \(dqheals\(dq the file.
  153. Consequently, if lost chunks were repaired earlier, it is advised to run
  154. \fB\-\-repair\fP a second time after creating some new backups.
  155. .SH OPTIONS
  156. .sp
  157. See \fIborg\-common(1)\fP for common options of Borg commands.
  158. .SS options
  159. .INDENT 0.0
  160. .TP
  161. .B \-\-repository\-only
  162. only perform repository checks
  163. .TP
  164. .B \-\-archives\-only
  165. only perform archives checks
  166. .TP
  167. .B \-\-verify\-data
  168. perform cryptographic archive data integrity verification (conflicts with \fB\-\-repository\-only\fP)
  169. .TP
  170. .B \-\-repair
  171. attempt to repair any inconsistencies found
  172. .TP
  173. .BI \-\-max\-duration \ SECONDS
  174. do only a partial repo check for max. SECONDS seconds (Default: unlimited)
  175. .UNINDENT
  176. .SS Archive filters
  177. .INDENT 0.0
  178. .TP
  179. .BI \-a \ PATTERN\fR,\fB \ \-\-match\-archives \ PATTERN
  180. only consider archive names matching the pattern. see \(dqborg help match\-archives\(dq.
  181. .TP
  182. .BI \-\-sort\-by \ KEYS
  183. Comma\-separated list of sorting keys; valid keys are: timestamp, name, id; default is: timestamp
  184. .TP
  185. .BI \-\-first \ N
  186. consider first N archives after other filters were applied
  187. .TP
  188. .BI \-\-last \ N
  189. consider last N archives after other filters were applied
  190. .TP
  191. .BI \-\-oldest \ TIMESPAN
  192. consider archives between the oldest archive\(aqs timestamp and (oldest + TIMESPAN), e.g. 7d or 12m.
  193. .TP
  194. .BI \-\-newest \ TIMESPAN
  195. consider archives between the newest archive\(aqs timestamp and (newest \- TIMESPAN), e.g. 7d or 12m.
  196. .TP
  197. .BI \-\-older \ TIMESPAN
  198. consider archives older than (now \- TIMESPAN), e.g. 7d oder 12m.
  199. .TP
  200. .BI \-\-newer \ TIMESPAN
  201. consider archives newer than (now \- TIMESPAN), e.g. 7d or 12m.
  202. .UNINDENT
  203. .SH SEE ALSO
  204. .sp
  205. \fIborg\-common(1)\fP
  206. .SH AUTHOR
  207. The Borg Collective
  208. .\" Generated by docutils manpage writer.
  209. .