workaround cleaning stale snapshots

This commit is contained in:
timeshifter
2022-02-03 19:51:14 +01:00
parent 85e3e0b60d
commit f23d277c5b
+3 -2
View File
@@ -679,6 +679,7 @@ class ExternalPool(Pool):
exit(EXIT_ERROR) exit(EXIT_ERROR)
def clean_old_snapshots(self) -> None: def clean_old_snapshots(self) -> None:
return # this seems to be broken TODO
print("Cleaning old snapshots") print("Cleaning old snapshots")
for dataset in self.datasets: for dataset in self.datasets:
dataset.clean_old_snapshots() dataset.clean_old_snapshots()
@@ -721,7 +722,7 @@ class Dataset:
for interval, number in config.keep_snapshots_per_interval.items(): for interval, number in config.keep_snapshots_per_interval.items():
self._clean_old_snapshots_for_interval(interval, number) self._clean_old_snapshots_for_interval(interval, number)
def _clean_old_snapshots_for_interval(self, interval: str, max_count: int) -> None: def _clean_old_snapshots_for_interval(self, interval: str, max_count: int) -> None: # TODO I assume the regex matches across different datasets, which it shouldn't
regex = _get_regex_matching_snapshots_with_tags([config.snapshot_tag, interval]) regex = _get_regex_matching_snapshots_with_tags([config.snapshot_tag, interval])
snapshots = [ snapshots = [
snapshot for snapshot in self.snapshots if snapshot.matches_regex(regex) snapshot for snapshot in self.snapshots if snapshot.matches_regex(regex)
@@ -752,7 +753,7 @@ class Snapshot:
def __repr__(self): def __repr__(self):
return str(self._path) return str(self._path)
def __eq__(self, other: ZFSPath): def __eq__(self, other: Snapshot):
return self._path == other._path return self._path == other._path
def newer_than(self, other: Snapshot) -> bool: def newer_than(self, other: Snapshot) -> bool: