goutte icon indicating copy to clipboard operation
goutte copied to clipboard

Enable more complex retention policies

Open MrMarlin opened this issue 5 years ago • 7 comments

It would be nice, to be able to set multiple retention "scope" like, keep:

  • One Snapshot for the last seven days (each day)
  • one Snapshot for the last four weeks (one Snapshot of each week)
  • one Snapshot for the last twelve months (one snapshot of each month)

MrMarlin avatar Feb 19 '20 08:02 MrMarlin

That could be nice to add indeed! As a workaround for now it is possible to achieve this by having multiple config files and running the goutte once per config.

etienne-napoleone avatar Feb 19 '20 09:02 etienne-napoleone

This was my first idea. But wouldn't my weekly config with retention=4 prune some of my weekly snapshots with retention=7, since there is no differentiation in the prefixes?

MrMarlin avatar Feb 19 '20 09:02 MrMarlin

Ah yes you're right, sorry it's been a while! I will see to refactor goutte to accept something like:

[droplets]
default_retention = 5

  [[droplets.by_name]]
  name = "server01"
  retention = 3

  [[droplets.by_name]]
  name = "server02"

  [[droplets.by_tag]]
  tag = "prod"
  retention = 20

[volumes]

  [[volumes.by_name]]
  # ...

etienne-napoleone avatar Feb 19 '20 10:02 etienne-napoleone

Oh I see I have described my idea a bit vaguely. I didn't mean different retentions for different volumens/droplets (this is also a really nice feature to have), but to have gaps between retentions of the same item.

For example I have a volume my_volume. For this volume I want multiple snapshots within the following timeframe:

  • 7 snapshots from the last seven days (Mo, Tu, We, Th, Fr, Sa, Su)
  • 4 snapshots from the last 4 weeks (Su, Su, Su, Su)
  • 12 snapshots from the last 12 Months (01.01., 01.02., 01.03. etc.)

So if I want to store a 10 month old snapshot, I don't have to keep 200 snapshots. At full retention this would only store 21 Snapshots (7+3+11)

Does that explanation make the idea a bit clearer? It's kinda hard to describe.

MrMarlin avatar Feb 19 '20 10:02 MrMarlin

Ah yes I see, totally makes sense!

One simple way to do it in conjuction with my change proposed above would be to update the snapshot naming to something like goutte-{??}-{droplet}-{date}-{hash}. ??? could be either the name of the config file or a name parameter from the config.

That would let you run:

  • daily goutte daily.toml which would create goutte-daily-server01-{date}-{hash} with retention of 7
  • weekly goutte weekly.toml which would create goutte-weekly-server01-{date}-{hash} with retention of 4
  • etc

Another way would be to completly change the internal logic, and define it in a cron style and jobs should check existing snapshots, compare it to the actual time and decide if it should start a snapshot. But that seems clunky as it's not a constantly running software.

etienne-napoleone avatar Feb 19 '20 10:02 etienne-napoleone

A yeah I see. So your first suggestion would work like a charm. Would really appreciate, if it was implemented. Thank you!

MrMarlin avatar Feb 19 '20 10:02 MrMarlin

Will be reworked in a new version 2

etienne-napoleone avatar Dec 03 '20 06:12 etienne-napoleone