prune.rst 2.0 KB

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