Duplicacy prune -keep-max PR submitted today

Hi, I submitted a pull request (PR) today to duplicacy to add a prune option -keep-max that allows you to specify a tag and how many snapshot revisions to keep for that tag, etc. This has frequently been requested (or at least something different than the current -keep logic).

If this is accepted by gilbertchen, I’ll update the prune wiki page, but for now, here’s a snippet of how it will work:

Quick overview

NAME:
   duplicacy prune - Prune revisions by number, tag, or retention policy

USAGE:
   duplicacy prune [command options]

OPTIONS:
   -id <snapshot id>            delete revisions with the specified snapshot ID instead of the default one
   -all, -a                     match against all snapshot IDs
   -r <revision> [+]            delete the specified revisions
   -t <tag> [+]                 delete revisions with the specified tags
   -keep <n:m> [+]              keep 1 revision every n days for revisions older than m days
   -keep-max <n>                keep max n most recent revisions matching the tag -t
   -exhaustive                  remove all unreferenced chunks (not just those referenced by deleted snapshots)
   -exclusive                   assume exclusive access to the storage (disable two-step fossil collection)
   -dry-run, -d                 show what would have been deleted
   -delete-only                 delete fossils previously collected (if deletable) and don't collect fossils
   -collect-only                identify and collect fossils, but don't delete fossils previously collected
   -ignore <id> [+]             ignore revisions with the specified snapshot ID when deciding if fossils can be deleted
   -storage <storage name>      prune revisions from the specified storage
   -threads <n>                 number of threads used to prune unreferenced chunks

Usage

duplicacy prune [command options]

Options

Options marked with [+] can be passed more than once.

-keep-max <n>

Keep max n most recent revisions for the specified tag -t.

A single tag -t must be specified when using -keep-max. The -keep-max and -keep options are mutually exclusive.

Examples:
duplicacy prune -keep-max 24 -t hourly    # Keep 24 most recent revisions with tag hourly
duplicacy prune -keep-max  7 -t daily     # Keep  7 most recent revisions with tag daily
duplicacy prune -keep-max  4 -t weekly    # Keep  4 most recent revisions with tag weekly
duplicacy prune -keep-max  3 -t monthly   # Keep  3 most recent revisions with tag monthly
duplicacy prune -keep-max  4 -t quarterly # Keep  4 most recent revisions with tag quarterly
duplicacy prune -keep-max  3 -t yearly    # Keep  3 most recent revisions with tag yearly

The -keep-max option must specify a number >= 0. If n is 0, all revisions matching the tag will be pruned. If n is greater than 0, then n of the most recent snapshot revisions will be kept.