plakar icon indicating copy to clipboard operation
plakar copied to clipboard

plakar prune does not take into account -policy

Open fredericull opened this issue 2 months ago • 0 comments

Describe the bug Since the fix to take account of -tag and other filters from command line (https://github.com/PlakarKorp/plakar/issues/1691) the -policy argument don't work anymore to define filters.

To Reproduce Steps to reproduce the behavior:

  1. mkdir plakar_demo
  2. plakar at plakar_demo create
  3. plakar at plakar_demo backup -tag daily,etc /etc
  4. plakar at plakar_demo backup -tag daily,www /var/www
  5. plakar at plakar_demo backup /etc
  6. plakar at plakar_demo backup /var/www
  7. plakar at plakar_demo ls -tags
    2025-10-21T20:33:53Z   6f2ea3da    10 MiB        0s /var/www
    2025-10-21T20:33:42Z   9b5cd90a   3.7 MiB        0s /etc
    2025-10-21T20:28:56Z   4206ded8    10 MiB        0s /var/www tags=daily,www
    2025-10-21T20:28:04Z   a8869196   3.7 MiB        1s /etc tags=daily,etc
    
  8. plakar at plakar_demo prune -minutes 1 -tag daily # Work as intended on plakar 1.0.5
    prune: would keep 0 and delete 2 snapshot(s), run with -apply to proceed
    delete   2025-10-21T20:28:56Z   4206ded8    10 MiB /var/www tags=daily,www  reason=outside retention windows
    delete   2025-10-21T20:28:04Z   a8869196   3.7 MiB /etc tags=daily,etc      reason=outside retention windows
    
  9. plakar policy show
    daily:
        filters:
            tags:
                - daily
    
  10. plakar at plakar_demo prune -minutes 1 -policy daily # Has worked in plakar 1.0.4, but not in 1.0.5
    prune: would keep 0 and delete 4 snapshot(s), run with -apply to proceed
    delete   2025-10-21T20:33:53Z   6f2ea3da    10 MiB /var/www                 reason=outside retention windows
    delete   2025-10-21T20:33:42Z   9b5cd90a   3.7 MiB /etc                     reason=outside retention windows
    delete   2025-10-21T20:28:56Z   4206ded8    10 MiB /var/www tags=daily,www  reason=outside retention windows
    delete   2025-10-21T20:28:04Z   a8869196   3.7 MiB /etc tags=daily,etc      reason=outside retention windows
    

Expected behavior That all arguments work to filters snapshots as explained in plakar help prune and https://plakar.io/docs/main/commands/plakar-prune/.

So for plakar at plakar_demo prune -minutes 1 -policy daily we expect that tag defined in policy is used to filter

prune: would keep 0 and delete 2 snapshot(s), run with -apply to proceed
delete   2025-10-21T20:28:56Z   4206ded8    10 MiB /var/www tags=daily,www  reason=outside retention windows
delete   2025-10-21T20:28:04Z   a8869196   3.7 MiB /etc tags=daily,etc      reason=outside retention windows

And for plakar at plakar_demo prune -minutes 1 -policy daily -tag etc we expect that tag defined in policy can be used and then completed with -tag argument

prune: would keep 0 and delete 1 snapshot(s), run with -apply to proceed
delete   2025-10-21T20:28:04Z   a8869196   3.7 MiB /etc tags=daily,etc      reason=outside retention windows

Desktop :

  • OS, OS Version and architecture: Debian GNU/Linux 12 (bookworm) / amd64
  • Plakar Version 1.0.5

Additional context plakar 1.0.4 prune filter only worked with policy and now plakar 1.0.5 filters only work with command line arguments.
This can lead to unwanted prune and lost some snapshots after the update when prune use policy to filter and has been scheduled via cron or other scheduler.

fredericull avatar Oct 21 '25 21:10 fredericull