prune.rst 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. .. include:: prune.rst.inc
  2. Examples
  3. ~~~~~~~~
  4. Be careful: prune is a potentially dangerous command; it will remove backup
  5. archives.
  6. By default, prune applies to **all archives in the repository** unless you
  7. restrict its operation to a subset of the archives using ``--glob-archives``.
  8. When using ``--glob-archives``, be careful to choose a good matching pattern —
  9. for example, do not use "foo*" if you do not also want to match "foobar".
  10. It is strongly recommended to always run ``prune -v --list --dry-run ...``
  11. first, so you can see what it would do without actually doing anything.
  12. ::
  13. # Keep 7 end-of-day and 4 additional end-of-week archives.
  14. # Do a dry-run without actually deleting anything.
  15. $ borg prune -v --list --dry-run --keep-daily=7 --keep-weekly=4 /path/to/repo
  16. # Same as above but only apply to archive names starting with the hostname
  17. # of the machine followed by a "-" character:
  18. $ borg prune -v --list --keep-daily=7 --keep-weekly=4 --glob-archives='{hostname}-*' /path/to/repo
  19. # Actually free disk space:
  20. $ borg compact /path/to/repo
  21. # Keep 7 end-of-day, 4 additional end-of-week archives,
  22. # and an end-of-month archive for every month:
  23. $ borg prune -v --list --keep-daily=7 --keep-weekly=4 --keep-monthly=-1 /path/to/repo
  24. # Keep all backups in the last 10 days, 4 additional end-of-week archives,
  25. # and an end-of-month archive for every month:
  26. $ borg prune -v --list --keep-within=10d --keep-weekly=4 --keep-monthly=-1 /path/to/repo
  27. There is also a visual example of pruning in ``docs/misc/prune-example.txt``:
  28. .. highlight:: none
  29. .. include:: ../misc/prune-example.txt
  30. :literal: