borg-prune.1 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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-09-08" "" "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]
  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. If you use \-\-match\-archives (\-a), then only archives that match the pattern are
  49. considered for deletion and only those archives count towards the totals
  50. specified by the rules.
  51. Otherwise, \fIall\fP archives in the repository are candidates for deletion!
  52. There is no automatic distinction between archives representing different
  53. contents. These need to be distinguished by specifying matching globs.
  54. .sp
  55. If you have multiple sequences of archives with different data sets (e.g.
  56. from different machines) in one shared repository, use one prune call per
  57. data set that matches only the respective archives using the \-\-match\-archives
  58. (\-a) option.
  59. .sp
  60. The \fB\-\-keep\-within\fP option takes an argument of the form \(dq<int><char>\(dq,
  61. where char is \(dqH\(dq, \(dqd\(dq, \(dqw\(dq, \(dqm\(dq, \(dqy\(dq. For example, \fB\-\-keep\-within 2d\fP means
  62. to keep all archives that were created within the past 48 hours.
  63. \(dq1m\(dq is taken to mean \(dq31d\(dq. The archives kept with this option do not
  64. count towards the totals specified by any other options.
  65. .sp
  66. A good procedure is to thin out more and more the older your backups get.
  67. As an example, \fB\-\-keep\-daily 7\fP means to keep the latest backup on each day,
  68. up to 7 most recent days with backups (days without backups do not count).
  69. The rules are applied from secondly to yearly, and backups selected by previous
  70. rules do not count towards those of later rules. The time that each backup
  71. starts is used for pruning purposes. Dates and times are interpreted in the local
  72. timezone of the system where borg prune runs, and weeks go from Monday to Sunday.
  73. Specifying a negative number of archives to keep means that there is no limit.
  74. As of borg 1.2.0, borg will retain the oldest archive if any of the secondly,
  75. minutely, hourly, daily, weekly, monthly, or yearly rules was not otherwise able to
  76. meet its retention target. This enables the first chronological archive to continue
  77. aging until it is replaced by a newer archive that meets the retention criteria.
  78. .sp
  79. The \fB\-\-keep\-last N\fP option is doing the same as \fB\-\-keep\-secondly N\fP (and it will
  80. keep the last N archives under the assumption that you do not create more than one
  81. backup archive in the same second).
  82. .sp
  83. You can influence how the \fB\-\-list\fP output is formatted by using the \fB\-\-short\fP
  84. option (less wide output) or by giving a custom format using \fB\-\-format\fP (see
  85. the \fBborg rlist\fP description for more details about the format string).
  86. .SH OPTIONS
  87. .sp
  88. See \fIborg\-common(1)\fP for common options of Borg commands.
  89. .SS optional arguments
  90. .INDENT 0.0
  91. .TP
  92. .B \-n\fP,\fB \-\-dry\-run
  93. do not change repository
  94. .TP
  95. .B \-\-list
  96. output verbose list of archives it keeps/prunes
  97. .TP
  98. .B \-\-short
  99. use a less wide archive part format
  100. .TP
  101. .B \-\-list\-pruned
  102. output verbose list of archives it prunes
  103. .TP
  104. .B \-\-list\-kept
  105. output verbose list of archives it keeps
  106. .TP
  107. .BI \-\-format \ FORMAT
  108. specify format for the archive part (default: \(dq{archive:<36} {time} [{id}]\(dq)
  109. .TP
  110. .BI \-\-keep\-within \ INTERVAL
  111. keep all archives within this time interval
  112. .TP
  113. .B \-\-keep\-last\fP,\fB \-\-keep\-secondly
  114. number of secondly archives to keep
  115. .TP
  116. .B \-\-keep\-minutely
  117. number of minutely archives to keep
  118. .TP
  119. .B \-H\fP,\fB \-\-keep\-hourly
  120. number of hourly archives to keep
  121. .TP
  122. .B \-d\fP,\fB \-\-keep\-daily
  123. number of daily archives to keep
  124. .TP
  125. .B \-w\fP,\fB \-\-keep\-weekly
  126. number of weekly archives to keep
  127. .TP
  128. .B \-m\fP,\fB \-\-keep\-monthly
  129. number of monthly archives to keep
  130. .TP
  131. .B \-y\fP,\fB \-\-keep\-yearly
  132. number of yearly archives to keep
  133. .UNINDENT
  134. .SS Archive filters
  135. .INDENT 0.0
  136. .TP
  137. .BI \-a \ PATTERN\fR,\fB \ \-\-match\-archives \ PATTERN
  138. only consider archive names matching the pattern. see \(dqborg help match\-archives\(dq.
  139. .TP
  140. .BI \-\-oldest \ TIMESPAN
  141. consider archives between the oldest archive\(aqs timestamp and (oldest + TIMESPAN), e.g. 7d or 12m.
  142. .TP
  143. .BI \-\-newest \ TIMESPAN
  144. consider archives between the newest archive\(aqs timestamp and (newest \- TIMESPAN), e.g. 7d or 12m.
  145. .TP
  146. .BI \-\-older \ TIMESPAN
  147. consider archives older than (now \- TIMESPAN), e.g. 7d or 12m.
  148. .TP
  149. .BI \-\-newer \ TIMESPAN
  150. consider archives newer than (now \- TIMESPAN), e.g. 7d or 12m.
  151. .UNINDENT
  152. .SH EXAMPLES
  153. .sp
  154. Be careful, prune is a potentially dangerous command, it will remove backup
  155. archives.
  156. .sp
  157. The default of prune is to apply to \fBall archives in the repository\fP unless
  158. you restrict its operation to a subset of the archives using \fB\-a\fP / \fB\-\-match\-archives\fP\&.
  159. When using \fB\-a\fP, be careful to choose a good pattern \- e.g. do not use a
  160. prefix \(dqfoo\(dq if you do not also want to match \(dqfoobar\(dq.
  161. .sp
  162. It is strongly recommended to always run \fBprune \-v \-\-list \-\-dry\-run ...\fP
  163. first so you will see what it would do without it actually doing anything.
  164. .INDENT 0.0
  165. .INDENT 3.5
  166. .sp
  167. .nf
  168. .ft C
  169. # Keep 7 end of day and 4 additional end of week archives.
  170. # Do a dry\-run without actually deleting anything.
  171. $ borg prune \-v \-\-list \-\-dry\-run \-\-keep\-daily=7 \-\-keep\-weekly=4
  172. # Same as above but only apply to archive names starting with the hostname
  173. # of the machine followed by a \(dq\-\(dq character:
  174. $ borg prune \-v \-\-list \-\-keep\-daily=7 \-\-keep\-weekly=4 \-a \(aqsh:{hostname}\-*\(aq
  175. # actually free disk space:
  176. $ borg compact
  177. # Keep 7 end of day, 4 additional end of week archives,
  178. # and an end of month archive for every month:
  179. $ borg prune \-v \-\-list \-\-keep\-daily=7 \-\-keep\-weekly=4 \-\-keep\-monthly=\-1
  180. # Keep all backups in the last 10 days, 4 additional end of week archives,
  181. # and an end of month archive for every month:
  182. $ borg prune \-v \-\-list \-\-keep\-within=10d \-\-keep\-weekly=4 \-\-keep\-monthly=\-1
  183. .ft P
  184. .fi
  185. .UNINDENT
  186. .UNINDENT
  187. .sp
  188. There is also a visualized prune example in \fBdocs/misc/prune\-example.txt\fP\&.
  189. .SH SEE ALSO
  190. .sp
  191. \fIborg\-common(1)\fP, \fIborg\-compact(1)\fP
  192. .SH AUTHOR
  193. The Borg Collective
  194. .\" Generated by docutils manpage writer.
  195. .