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.

Dear Devs! When do we get something like this? The current implementation of pruning options is super confusing. I spend now days to understand and tweaking the prune command and still not 100% if the settings I have now are really the ones that I actually want. Thanks!

Hi, I wound up changing the prune option to -keep-days instead of -keep-max. If you’d like to try out keep days, I forked the repo and have a build here that includes the -keep-days prune option:

Hi, I forked the duplicacy repository and have added an option to the prune command named --keep-days, which allows you to specify the number of days you wish to keep snapshot revisions. Works great in conjunction with the prune tag command, i.e. duplicacy prune -t daily -keep-days 7

You can download from here if you’d like to try it out:

How is this different from -keep 0:7?

(Please don’t post the same thing in multiple topics. I moved all those posts here and deleted duplicates)

It’s more straight forward IMHO.