apreiml/prunef

multiple formats (or reguar expression matching)

Opened this issue · 3 comments

Perhaps an option to include multiple matches, especially when there is hourly/monthly/frequent snapshots already pre-created or a naming change happened.

I also have the case where I did not change an error in the backup filename format yet, because of prunef.
I've accidentally switched the month with the day like backup-2021-09-05 which is annoying, because it's not sorted properly.

Though adding the possibility to include multiple matches may lead to annoying issues. Like if I would change my format to %m-%d and add %d-%m and %m-%d as format options to prunef, new entries will also be parsed with the old format, if the day is below 13, which may result in the unexpected loss of backups.

So I'm rather against adding this option.

A fix would be just to rename the old filenames, but what can one do, if renaming is not possible?

swapping things like %d-%m and %m-%d is not my example, but rather similar to my example I gave on the other issue:

zfs list -t snap  data1/ClientA/mariadb04_log > /tmp/list
grep frequent /tmp/list | prunef --keep-minutely 2880 --keep-hourly 48 'data1/ClientA/mariadb04_log@zfs-auto-snap_frequent-%Y-%m-%d-%H%M'
grep hourly /tmp/list  | prunef --keep-hourly 336  'data1/ClientA/mariadb04_log@zfs-auto-snap_hourly-%Y-%m-%d-%H%M'
grep daily /tmp/list  | prunef --keep-weekly 12 --keep-monthly 24 --keep-yearly 20 --keep-daily 30  'data1/ClientA/mariadb04_log@zfs-auto-snap_daily-%Y-%m-%d-%H%M'

I'd actually would've like to "merge" these (reason for my regex type request). These names comes from a different system, and sometimes those daily gets missed for known reasons related to the up syncing and those getting removed before the sync, and why I'd like to then continue using the best frequent (in the absence of hourly/daily).

Would save me to do continuous (on the receiving side) renames, but again, if there are reasons for not implementing, I'll handle it accordingly

There is no reason against implementing. I'm just considering options and possible disadvantages that may arise when implementing.

What about glob? https://pkg.go.dev/path#Match would this work for your case? You could maybe make a rule like data1/ClientA/mariadb04_log@zfs-auto-snap_*-%Y-%m-%d-%H%M