borg-prune.1 7.1 KB

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