forget: Add --keep-within-hourly (and friends)

Allow keeping hourly/daily/weekly/monthly/yearly snapshots for a given time period.

This adds the following flags/parameters to restic forget:
  --keep-within-hourly duration
  --keep-within-daily duration
  --keep-within-weekly duration
  --keep-within-monthly duration
  --keep-within-yearly duration

Includes following changes:
  - Add tests for --keep-within-hourly (and friends)
  - Add documentation for --keep-within-hourly (and friends)
  - Add changelog for --keep-within-hourly (and friends)
This commit is contained in:
Magnus Thor Torfason
2021-07-24 16:14:43 +00:00
parent c707d71b72
commit 74ebc650ab
11 changed files with 2580 additions and 25 deletions
+22
View File
@@ -190,6 +190,18 @@ The ``forget`` command accepts the following parameters:
years, months, days, and hours, e.g. ``2y5m7d3h`` will keep all snapshots
made in the two years, five months, seven days, and three hours before the
latest snapshot.
- ``--keep-within-hourly duration`` keep all hourly snapshots made within
specified duration of the latest snapshot. The duration is specified in
the same way as for ``--keep-within`` and the method for determining
hourly snapshots is the same as for ``--keep-hourly``.
- ``--keep-within-daily duration`` keep all daily snapshots made within
specified duration of the latest snapshot.
- ``--keep-within-weekly duration`` keep all weekly snapshots made within
specified duration of the latest snapshot.
- ``--keep-within-monthly duration`` keep all monthly snapshots made within
specified duration of the latest snapshot.
- ``--keep-within-yearly duration`` keep all yearly snapshots made within
specified duration of the latest snapshot.
.. note:: All calendar related ``--keep-*`` options work on the natural time
boundaries and not relative to when you run the ``forget`` command. Weeks
@@ -305,6 +317,16 @@ last-day-of-the-months (11 or 12 depends if the 5 weeklies cross a month).
And finally 75 last-day-of-the-year snapshots. All other snapshots are
removed.
You might want to maintain the same policy as for the example above, but have
irregular backups. For example, the 7 snapshots specified with ``--keep-daily 7``
might be spread over a longer period. If what you want is to keep daily snapshots
for a week, weekly for a month, monthly for a year and yearly for 75 years, you
could specify:
``forget --keep-daily-within 7d --keep-weekly-within 1m --keep-monthly-within 1y
--keep-yearly-within 75y``
(Note that `1w` is not a recognized duration, so you will have to specify
`7d` instead)
Customize pruning
*****************