2
0

borg-prune.1 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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 "2024-10-31" "" "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] [NAME]
  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.
  40. .sp
  41. Important: Repository disk space is \fBnot\fP freed until you run \fBborg compact\fP\&.
  42. .sp
  43. This command is normally used by automated backup scripts wanting to keep a
  44. certain number of historic backups. This retention policy is commonly referred to as
  45. \fI\%GFS\fP
  46. (Grandfather\-father\-son) backup rotation scheme.
  47. .sp
  48. The recommended way to use prune is to give the archive series name to it via the
  49. NAME argument (assuming you have the same name for all archives in a series).
  50. Alternatively, you can also use \-\-match\-archives (\-a), then only archives that
  51. match the pattern are considered for deletion and only those archives count
  52. towards the totals 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 globs.
  56. .sp
  57. If you have multiple series of archives with different data sets (e.g.
  58. from different machines) in one shared repository, use one prune call per
  59. series.
  60. .sp
  61. The \fB\-\-keep\-within\fP option takes an argument of the form \(dq<int><char>\(dq,
  62. where char is \(dqH\(dq, \(dqd\(dq, \(dqw\(dq, \(dqm\(dq, \(dqy\(dq. For example, \fB\-\-keep\-within 2d\fP means
  63. to keep all archives that were created within the past 48 hours.
  64. \(dq1m\(dq is taken to mean \(dq31d\(dq. 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 the local
  73. timezone of the system where borg prune runs, and weeks go from Monday to Sunday.
  74. Specifying a negative number of archives to keep means that there is no limit.
  75. .sp
  76. Borg will retain the oldest archive if any of the secondly, minutely, hourly,
  77. daily, weekly, monthly, quarterly, or yearly rules was not otherwise able to
  78. meet its retention target. This enables the first chronological archive to
  79. continue aging until it is replaced by a newer archive that meets the retention
  80. criteria.
  81. .sp
  82. The \fB\-\-keep\-13weekly\fP and \fB\-\-keep\-3monthly\fP rules are two different
  83. strategies for keeping archives every quarter year.
  84. .sp
  85. The \fB\-\-keep\-last N\fP option is doing the same as \fB\-\-keep\-secondly N\fP (and it will
  86. keep the last N archives under the assumption that you do not create more than one
  87. backup archive in the same second).
  88. .sp
  89. You can influence how the \fB\-\-list\fP output is formatted by using the \fB\-\-short\fP
  90. option (less wide output) or by giving a custom format using \fB\-\-format\fP (see
  91. the \fBborg repo\-list\fP description for more details about the format string).
  92. .SH OPTIONS
  93. .sp
  94. See \fIborg\-common(1)\fP for common options of Borg commands.
  95. .SS arguments
  96. .INDENT 0.0
  97. .TP
  98. .B NAME
  99. specify the archive name
  100. .UNINDENT
  101. .SS optional arguments
  102. .INDENT 0.0
  103. .TP
  104. .B \-n\fP,\fB \-\-dry\-run
  105. do not change repository
  106. .TP
  107. .B \-\-list
  108. output verbose list of archives it keeps/prunes
  109. .TP
  110. .B \-\-short
  111. use a less wide archive part format
  112. .TP
  113. .B \-\-list\-pruned
  114. output verbose list of archives it prunes
  115. .TP
  116. .B \-\-list\-kept
  117. output verbose list of archives it keeps
  118. .TP
  119. .BI \-\-format \ FORMAT
  120. specify format for the archive part (default: \(dq{archive:<36} {time} [{id}]\(dq)
  121. .TP
  122. .BI \-\-keep\-within \ INTERVAL
  123. keep all archives within this time interval
  124. .TP
  125. .B \-\-keep\-last\fP,\fB \-\-keep\-secondly
  126. number of secondly archives to keep
  127. .TP
  128. .B \-\-keep\-minutely
  129. number of minutely archives to keep
  130. .TP
  131. .B \-H\fP,\fB \-\-keep\-hourly
  132. number of hourly archives to keep
  133. .TP
  134. .B \-d\fP,\fB \-\-keep\-daily
  135. number of daily archives to keep
  136. .TP
  137. .B \-w\fP,\fB \-\-keep\-weekly
  138. number of weekly archives to keep
  139. .TP
  140. .B \-m\fP,\fB \-\-keep\-monthly
  141. number of monthly archives to keep
  142. .TP
  143. .B \-\-keep\-13weekly
  144. number of quarterly archives to keep (13 week strategy)
  145. .TP
  146. .B \-\-keep\-3monthly
  147. number of quarterly archives to keep (3 month strategy)
  148. .TP
  149. .B \-y\fP,\fB \-\-keep\-yearly
  150. number of yearly archives to keep
  151. .UNINDENT
  152. .SS Archive filters
  153. .INDENT 0.0
  154. .TP
  155. .BI \-a \ PATTERN\fR,\fB \ \-\-match\-archives \ PATTERN
  156. only consider archives matching all patterns. see \(dqborg help match\-archives\(dq.
  157. .TP
  158. .BI \-\-oldest \ TIMESPAN
  159. consider archives between the oldest archive\(aqs timestamp and (oldest + TIMESPAN), e.g. 7d or 12m.
  160. .TP
  161. .BI \-\-newest \ TIMESPAN
  162. consider archives between the newest archive\(aqs timestamp and (newest \- TIMESPAN), e.g. 7d or 12m.
  163. .TP
  164. .BI \-\-older \ TIMESPAN
  165. consider archives older than (now \- TIMESPAN), e.g. 7d or 12m.
  166. .TP
  167. .BI \-\-newer \ TIMESPAN
  168. consider archives newer than (now \- TIMESPAN), e.g. 7d or 12m.
  169. .UNINDENT
  170. .SH EXAMPLES
  171. .sp
  172. Be careful, prune is a potentially dangerous command, it will remove backup
  173. archives.
  174. .sp
  175. The default of prune is to apply to \fBall archives in the repository\fP unless
  176. you restrict its operation to a subset of the archives.
  177. .sp
  178. The recommended way to name archives (with \fBborg create\fP) is to use the
  179. identical archive name within a series of archives. Then you can simply give
  180. that name to prune also, so it operates just on that series of archives.
  181. .sp
  182. Alternatively, you can use \fB\-a\fP / \fB\-\-match\-archives\fP to do a match on the
  183. archive names to select some of them.
  184. When using \fB\-a\fP, be careful to choose a good pattern \- e.g. do not use a
  185. prefix \(dqfoo\(dq if you do not also want to match \(dqfoobar\(dq.
  186. .sp
  187. It is strongly recommended to always run \fBprune \-v \-\-list \-\-dry\-run ...\fP
  188. first so you will see what it would do without it actually doing anything.
  189. .sp
  190. Don\(aqt forget to run \fBborg compact \-v\fP after prune to actually free disk space.
  191. .INDENT 0.0
  192. .INDENT 3.5
  193. .sp
  194. .nf
  195. .ft C
  196. # Keep 7 end of day and 4 additional end of week archives.
  197. # Do a dry\-run without actually deleting anything.
  198. $ borg prune \-v \-\-list \-\-dry\-run \-\-keep\-daily=7 \-\-keep\-weekly=4
  199. # Similar as above but only apply to the archive series named \(aq{hostname}\(aq:
  200. $ borg prune \-v \-\-list \-\-keep\-daily=7 \-\-keep\-weekly=4 \(aq{hostname}\(aq
  201. # Similar as above but apply to archive names starting with the hostname
  202. # of the machine followed by a \(dq\-\(dq character:
  203. $ borg prune \-v \-\-list \-\-keep\-daily=7 \-\-keep\-weekly=4 \-a \(aqsh:{hostname}\-*\(aq
  204. # Keep 7 end of day, 4 additional end of week archives,
  205. # and an end of month archive for every month:
  206. $ borg prune \-v \-\-list \-\-keep\-daily=7 \-\-keep\-weekly=4 \-\-keep\-monthly=\-1
  207. # Keep all backups in the last 10 days, 4 additional end of week archives,
  208. # and an end of month archive for every month:
  209. $ borg prune \-v \-\-list \-\-keep\-within=10d \-\-keep\-weekly=4 \-\-keep\-monthly=\-1
  210. .ft P
  211. .fi
  212. .UNINDENT
  213. .UNINDENT
  214. .sp
  215. There is also a visualized prune example in \fBdocs/misc/prune\-example.txt\fP\&.
  216. .SH SEE ALSO
  217. .sp
  218. \fIborg\-common(1)\fP, \fIborg\-compact(1)\fP
  219. .SH AUTHOR
  220. The Borg Collective
  221. .\" Generated by docutils manpage writer.
  222. .