On Sat, Jul 06, 2013 at 06:04:50PM +0200, Jan Ritzerfeld wrote:
Am Samstag, 6. Juli 2013, 15:55:23 schrieb Arvin Schnell:
On Sat, Jul 06, 2013 at 02:18:44PM +0200, Jan Ritzerfeld wrote:
TIMELINE_LIMIT_* does not: TIMELINE_LIMIT_HOURLY=5 keeps the last five snapshots and not only five hourly snapshots per day. And although I set TIMELINE_LIMIT_DAILY=5 and the rest 0, there are still snapshots made eight days ago (five hourly and five daily).
Could be because the cleanup algorithm only runs once a day. [...]
Hmm, no. I manually did a "snapper cleanup timeline". ATM, I am looking at client/cleanup.cc. And the code indeed does what I observed. do_cleanup_timeline fetches a full list of timeline snapshots and then removes the ones that should be kept. The remaining snapshots will be deleted:
if (num_hourly < limit_hourly && is_first_hourly(it, tmp.end(), *it)) { ++num_hourly; it = tmp.erase(it); } else if (num_daily < limit_daily && is_first_daily(it, tmp.end(), *it)) { ++num_daily; it = tmp.erase(it); } else if...
Obviously, if all snapshots are both the first hourly and the first daily, they will be only counted for the hourly limit. This is wrong, because you will get "limit_daily" additional snapshots (if there are enough left). The same holds true for monthly and yearly. The correct code would be little bit more complicated:
bool keep = false; if (num_hourly < limit_hourly && is_first_hourly(it, tmp.end(), *it)) { ++num_hourly; keep = true; } if (num_daily < limit_daily && is_first_daily(it, tmp.end(), *it)) { ++num_daily; keep = true; } if (num_monthly < limit_monthly && is_first_monthly(it, tmp.end(), *it)) { ++num_monthly; keep = true; } if (num_yearly < limit_yearly && is_first_yearly(it, tmp.end(), *it)) { ++num_yearly; keep = true; } if (keep) { it = tmp.erase(it); } else { ++it; }
The result of the modified code is indeed easier to understand. I have changed snapper and also added a manpage snapper-configs(5). Regards, Arvin -- Arvin Schnell, <aschnell@suse.de> Senior Software Engineer, Research & Development SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) Maxfeldstraße 5 90409 Nürnberg Germany -- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-factory+owner@opensuse.org