borg-prune.1 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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-PRUNE" 1 "2022-06-04" "" "borg backup tool"
  31. .SH NAME
  32. borg-prune \- Prune repository archives according to specified rules
  33. .SH SYNOPSIS
  34. .sp
  35. borg [common options] prune [options] [REPOSITORY]
  36. .SH DESCRIPTION
  37. .sp
  38. The prune command prunes a repository by deleting all archives not matching
  39. any of the specified retention options. This command is normally used by
  40. automated backup scripts wanting to keep a certain number of historic backups.
  41. This retention policy is commonly referred to as
  42. \fI\%GFS\fP
  43. (Grandfather\-father\-son) backup rotation scheme.
  44. .sp
  45. Also, prune automatically removes checkpoint archives (incomplete archives left
  46. behind by interrupted backup runs) except if the checkpoint is the latest
  47. archive (and thus still needed). Checkpoint archives are not considered when
  48. comparing archive counts against the retention limits (\fB\-\-keep\-X\fP).
  49. .sp
  50. If a prefix is set with \-P, then only archives that start with the prefix are
  51. considered for deletion and only those archives count towards the totals
  52. specified by the rules.
  53. Otherwise, \fIall\fP archives in the repository are candidates for deletion!
  54. There is no automatic distinction between archives representing different
  55. contents. These need to be distinguished by specifying matching prefixes.
  56. .sp
  57. If you have multiple sequences of archives with different data sets (e.g.
  58. from different machines) in one shared repository, use one prune call per
  59. data set that matches only the respective archives using the \-P option.
  60. .sp
  61. The \fB\-\-keep\-within\fP option takes an argument of the form "<int><char>",
  62. where char is "H", "d", "w", "m", "y". For example, \fB\-\-keep\-within 2d\fP means
  63. to keep all archives that were created within the past 48 hours.
  64. "1m" is taken to mean "31d". The archives kept with this option do not
  65. count towards the totals specified by any other options.
  66. .sp
  67. A good procedure is to thin out more and more the older your backups get.
  68. As an example, \fB\-\-keep\-daily 7\fP means to keep the latest backup on each day,
  69. up to 7 most recent days with backups (days without backups do not count).
  70. The rules are applied from secondly to yearly, and backups selected by previous
  71. rules do not count towards those of later rules. The time that each backup
  72. starts is used for pruning purposes. Dates and times are interpreted in
  73. the local timezone, and weeks go from Monday to Sunday. Specifying a
  74. negative number of archives to keep means that there is no limit.
  75. .sp
  76. The \fB\-\-keep\-last N\fP option is doing the same as \fB\-\-keep\-secondly N\fP (and it will
  77. keep the last N archives under the assumption that you do not create more than one
  78. backup archive in the same second).
  79. .sp
  80. When using \fB\-\-stats\fP, you will get some statistics about how much data was
  81. deleted \- the "Deleted data" deduplicated size there is most interesting as
  82. that is how much your repository will shrink.
  83. Please note that the "All archives" stats refer to the state after pruning.
  84. .SH OPTIONS
  85. .sp
  86. See \fIborg\-common(1)\fP for common options of Borg commands.
  87. .SS arguments
  88. .INDENT 0.0
  89. .TP
  90. .B REPOSITORY
  91. repository to prune
  92. .UNINDENT
  93. .SS optional arguments
  94. .INDENT 0.0
  95. .TP
  96. .B \-n\fP,\fB \-\-dry\-run
  97. do not change repository
  98. .TP
  99. .B \-\-force
  100. force pruning of corrupted archives, use \fB\-\-force \-\-force\fP in case \fB\-\-force\fP does not work.
  101. .TP
  102. .B \-s\fP,\fB \-\-stats
  103. print statistics for the deleted archive
  104. .TP
  105. .B \-\-list
  106. output verbose list of archives it keeps/prunes
  107. .TP
  108. .BI \-\-keep\-within \ INTERVAL
  109. keep all archives within this time interval
  110. .TP
  111. .B \-\-keep\-last\fP,\fB \-\-keep\-secondly
  112. number of secondly archives to keep
  113. .TP
  114. .B \-\-keep\-minutely
  115. number of minutely archives to keep
  116. .TP
  117. .B \-H\fP,\fB \-\-keep\-hourly
  118. number of hourly archives to keep
  119. .TP
  120. .B \-d\fP,\fB \-\-keep\-daily
  121. number of daily archives to keep
  122. .TP
  123. .B \-w\fP,\fB \-\-keep\-weekly
  124. number of weekly archives to keep
  125. .TP
  126. .B \-m\fP,\fB \-\-keep\-monthly
  127. number of monthly archives to keep
  128. .TP
  129. .B \-y\fP,\fB \-\-keep\-yearly
  130. number of yearly archives to keep
  131. .TP
  132. .B \-\-save\-space
  133. work slower, but using less space
  134. .UNINDENT
  135. .SS Archive filters
  136. .INDENT 0.0
  137. .TP
  138. .BI \-P \ PREFIX\fR,\fB \ \-\-prefix \ PREFIX
  139. only consider archive names starting with this prefix.
  140. .TP
  141. .BI \-a \ GLOB\fR,\fB \ \-\-glob\-archives \ GLOB
  142. only consider archive names matching the glob. sh: rules apply, see "borg help patterns". \fB\-\-prefix\fP and \fB\-\-glob\-archives\fP are mutually exclusive.
  143. .UNINDENT
  144. .SH EXAMPLES
  145. .sp
  146. Be careful, prune is a potentially dangerous command, it will remove backup
  147. archives.
  148. .sp
  149. The default of prune is to apply to \fBall archives in the repository\fP unless
  150. you restrict its operation to a subset of the archives using \fB\-\-prefix\fP\&.
  151. When using \fB\-\-prefix\fP, be careful to choose a good prefix \- e.g. do not use a
  152. prefix "foo" if you do not also want to match "foobar".
  153. .sp
  154. It is strongly recommended to always run \fBprune \-v \-\-list \-\-dry\-run ...\fP
  155. first so you will see what it would do without it actually doing anything.
  156. .INDENT 0.0
  157. .INDENT 3.5
  158. .sp
  159. .nf
  160. .ft C
  161. # Keep 7 end of day and 4 additional end of week archives.
  162. # Do a dry\-run without actually deleting anything.
  163. $ borg prune \-v \-\-list \-\-dry\-run \-\-keep\-daily=7 \-\-keep\-weekly=4 /path/to/repo
  164. # Same as above but only apply to archive names starting with the hostname
  165. # of the machine followed by a "\-" character:
  166. $ borg prune \-v \-\-list \-\-keep\-daily=7 \-\-keep\-weekly=4 \-\-prefix=\(aq{hostname}\-\(aq /path/to/repo
  167. # Keep 7 end of day, 4 additional end of week archives,
  168. # and an end of month archive for every month:
  169. $ borg prune \-v \-\-list \-\-keep\-daily=7 \-\-keep\-weekly=4 \-\-keep\-monthly=\-1 /path/to/repo
  170. # Keep all backups in the last 10 days, 4 additional end of week archives,
  171. # and an end of month archive for every month:
  172. $ borg prune \-v \-\-list \-\-keep\-within=10d \-\-keep\-weekly=4 \-\-keep\-monthly=\-1 /path/to/repo
  173. .ft P
  174. .fi
  175. .UNINDENT
  176. .UNINDENT
  177. .sp
  178. There is also a visualized prune example in \fBdocs/misc/prune\-example.txt\fP\&.
  179. .SH SEE ALSO
  180. .sp
  181. \fIborg\-common(1)\fP
  182. .SH AUTHOR
  183. The Borg Collective
  184. .\" Generated by docutils manpage writer.
  185. .