From 3b2a19d492a38fd25fea3fe8cb3e82c267ac0f15 Mon Sep 17 00:00:00 2001 From: Edwin Eefting Date: Tue, 25 Feb 2020 00:58:25 +0100 Subject: [PATCH] migrate/other-snapshot feature almost done --- bin/zfs-autobackup | 111 ++++++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 56 deletions(-) diff --git a/bin/zfs-autobackup b/bin/zfs-autobackup index 2dccb86..ace6698 100755 --- a/bin/zfs-autobackup +++ b/bin/zfs-autobackup @@ -26,7 +26,7 @@ try: except ImportError: use_color=False -VERSION="3.0-rc4" +VERSION="3.0-rc4.1" class Log: @@ -580,36 +580,35 @@ class ZfsDataset(): return(ZfsDataset(self.zfs_node, self.rstrip_path(1))) - def find_our_prev_snapshot(self, snapshot): - """find our previous snapshot in this dataset. None if it doesnt exist""" + def find_prev_snapshot(self, snapshot, other_snapshots=False): + """find previous snapshot in this dataset. None if it doesnt exist. + + other_snapshots: set to true to also return snapshots that where not created by us. (is_ours) + """ if self.is_snapshot: raise(Exception("Please call this on a dataset.")) - try: - index=self.find_our_snapshot_index(snapshot) - if index!=None and index>0: - return(self.our_snapshots[index-1]) - else: - return(None) - except: - return(None) + index=self.find_snapshot_index(snapshot) + while index: + index=index-1 + if other_snapshots or self.snapshots[index].is_ours(): + return(self.snapshots[index]) + return(None) - def find_our_next_snapshot(self, snapshot): - """find our next snapshot in this dataset. None if it doesnt exist""" + def find_next_snapshot(self, snapshot, other_snapshots=False): + """find next snapshot in this dataset. None if it doesnt exist""" if self.is_snapshot: raise(Exception("Please call this on a dataset.")) - try: - index=self.find_our_snapshot_index(snapshot) - if index!=None and index>=0 and index