2
0

borg-prune.1 8.4 KB

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