2017-06-06 22:06:36 +00:00
|
|
|
.. include:: prune.rst.inc
|
|
|
|
|
|
|
|
Examples
|
|
|
|
~~~~~~~~
|
|
|
|
|
|
|
|
Be careful, prune is a potentially dangerous command, it will remove backup
|
|
|
|
archives.
|
|
|
|
|
|
|
|
The default of prune is to apply to **all archives in the repository** unless
|
2024-09-18 12:05:12 +00:00
|
|
|
you restrict its operation to a subset of the archives.
|
|
|
|
|
|
|
|
The recommended way to name archives (with ``borg create``) is to use the
|
|
|
|
identical archive name within a series of archives. Then you can simply give
|
|
|
|
that name to prune also, so it operates just on that series of archives.
|
|
|
|
|
|
|
|
Alternatively, you can use ``-a`` / ``--match-archives`` to do a match on the
|
|
|
|
archive names to select some of them.
|
2022-07-02 18:52:41 +00:00
|
|
|
When using ``-a``, be careful to choose a good pattern - e.g. do not use a
|
2017-06-06 22:06:36 +00:00
|
|
|
prefix "foo" if you do not also want to match "foobar".
|
|
|
|
|
|
|
|
It is strongly recommended to always run ``prune -v --list --dry-run ...``
|
|
|
|
first so you will see what it would do without it actually doing anything.
|
|
|
|
|
2024-09-18 12:05:12 +00:00
|
|
|
Don't forget to run ``borg compact -v`` after prune to actually free disk space.
|
|
|
|
|
2017-06-06 22:06:36 +00:00
|
|
|
::
|
|
|
|
|
|
|
|
# Keep 7 end of day and 4 additional end of week archives.
|
|
|
|
# Do a dry-run without actually deleting anything.
|
2022-06-23 23:19:19 +00:00
|
|
|
$ borg prune -v --list --dry-run --keep-daily=7 --keep-weekly=4
|
2017-06-06 22:06:36 +00:00
|
|
|
|
2024-09-18 12:05:12 +00:00
|
|
|
# Similar as above but only apply to the archive series named '{hostname}':
|
|
|
|
$ borg prune -v --list --keep-daily=7 --keep-weekly=4 '{hostname}'
|
|
|
|
|
|
|
|
# Similar as above but apply to archive names starting with the hostname
|
2017-06-06 22:06:36 +00:00
|
|
|
# of the machine followed by a "-" character:
|
2023-05-15 22:50:50 +00:00
|
|
|
$ borg prune -v --list --keep-daily=7 --keep-weekly=4 -a 'sh:{hostname}-*'
|
2017-06-06 22:06:36 +00:00
|
|
|
|
|
|
|
# Keep 7 end of day, 4 additional end of week archives,
|
|
|
|
# and an end of month archive for every month:
|
2022-06-23 23:19:19 +00:00
|
|
|
$ borg prune -v --list --keep-daily=7 --keep-weekly=4 --keep-monthly=-1
|
2017-06-06 22:06:36 +00:00
|
|
|
|
|
|
|
# Keep all backups in the last 10 days, 4 additional end of week archives,
|
|
|
|
# and an end of month archive for every month:
|
2022-06-23 23:19:19 +00:00
|
|
|
$ borg prune -v --list --keep-within=10d --keep-weekly=4 --keep-monthly=-1
|
2017-06-23 15:03:04 +00:00
|
|
|
|
2017-06-23 17:16:33 +00:00
|
|
|
There is also a visualized prune example in ``docs/misc/prune-example.txt``:
|
2017-06-23 15:03:04 +00:00
|
|
|
|
2017-06-23 17:16:33 +00:00
|
|
|
.. highlight:: none
|
|
|
|
.. include:: ../misc/prune-example.txt
|
2017-06-23 15:03:04 +00:00
|
|
|
:literal:
|