borg-prune.1 7.0 KB

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