Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep last n items #5

Open
OE2WNL opened this issue Mar 31, 2018 · 3 comments
Open

Keep last n items #5

OE2WNL opened this issue Mar 31, 2018 · 3 comments

Comments

@OE2WNL
Copy link

OE2WNL commented Mar 31, 2018

Usecase - productive ZFS server makes snapshots via cronjob every 0 and 30 minutes after the hour and only once a day these snapshots are transfered offsite to another server with zfs send command.

After transfering snapshots to offsite system I would like to clear some snapshots on productive system. But I must assure to keep (in any case) the last snapshot for the next incremental zfs send - so a keeplast1 would be needed.

Another usecase from this would be that on the productive Server I would like to assure to keep the latest 10 snapshots in any case (independed of creation time).
Everything after the 10 recent snapshots can be thinned out with hours,days,weeks etc.

So categorie keeplast would be helpfull.

Probably a helpful source would be the program Restic Backup
I use Restic for some other backups and that's where I'm used to have a keep-last parameter.

Again ;-) interessted in your thoughts.
Greetings Wolfgang

@bhelm
Copy link

bhelm commented Aug 21, 2018

I initially thought this is what "recent" is about. I thought wrong. After 2,2TB and a successful snapshot transfer, it chose to delete the last and only source snapshot :(

After some testing, i think "recent" should be named "hours".

+1 for keeplast implementation. I would call it "latest" and rename recent to hours.

@jgehrcke
Copy link
Owner

Thanks for the feedback Wolfgang and Bernd!

I agree that the paradigm of "keep the last N" is intuitively useful. In fact, that is what I thought initially. But things seem to be a little more complicated than that.

The following example hopefully shows that simply keeping the last N can result in data loss, too, when invoking timegaps very frequently.

An item younger than 1 hour is in the "recent" category.

Let's imagine timegaps was to keep the 5 most recent (as you wrote, the 5 last or newest items) in that category.

Let's imagine items are created at a high rate, e.g. every two minutes. Let's consider the case where timegaps is invoked at a high rate, too (many times per hour, regularly or irregularly).

In this example scenario items would be deleted before they get to be 1 hour old. Propagation of the older items would not happen; and timegaps would break one of its promises.

It is precisely this effect which made me switch to the "keep the oldest items" paradigm. I seem to have thought about that a few years ago and wrote this into the TODO file:

For recent items, we should also keep the older ones so that it is safe to
invoke timegaps at any time and at any frequency. In the extreme case this
will reject the newest backup and only keep the almost-one-hour-old one,
but this is predictable and can be reliably worked around by the user. If
we rejected the oldest recent items, however, sudden frequent invocation
of item creation and timegaps would reject older items. Instead, sudden
frequent invocation of item creation and timegaps should reject the
unnecessary amount of newer items.

Got that from here:

timegaps/TODO

Line 29 in fffaf13

- For recent items, we should also keep the older ones so that it is safe to
(thanks to past Jan-Philip for writing some things down)

Now, you brought up very valid concerns. What can we do?

What if we were to keep the oldest N and the newest M in the "recent" category (again, this is where all items are in that are younger than 1 hour)? That would ensure backpropagation of the oldest items. In an extreme case it could still rip a hole of <1 hour into the item distribution, though. In terms of thinning data out this should be desired. However, if that is a problem in any workflow the only viable solution is to add another time category with a more fine-grained resolution than 1 hour.

This is just me thinking out loud!

@jgehrcke
Copy link
Owner

Related: #3 (comment)

Another relevant thought: not thinning out in the "recent" category should be an option. Is it currently?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants