diff --git a/zfs_autobackup b/zfs_autobackup index d5466c7..62156af 100755 --- a/zfs_autobackup +++ b/zfs_autobackup @@ -456,12 +456,13 @@ class ZfsDataset(): """ - def __init__(self, zfs_node, name, exists=None): + def __init__(self, zfs_node, name, force_exists=None): """name: full path of the zfs dataset exists: specifiy if you already know a dataset exists or not. for performance reasons. (othewise it will have to check with zfs list when needed) """ self.zfs_node=zfs_node self.name=name #full name + self.force_exists=force_exists def __repr__(self): return("{}: {}".format(self.zfs_node, self.name)) @@ -486,6 +487,7 @@ class ZfsDataset(): """clear cache""" #TODO: nicer? self._cached_properties={} + self.force_exists=None def lstrip_path(self,count): @@ -531,13 +533,45 @@ 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""" + + if self.is_snapshot(): + raise(Exception("Please call this on a dataset.") + + try: + index=self.our_snapshots.index(snapshot) + if index>0: + return(self.our_snapshots[index-1]) + else: + return(None) + except: + return(None) + + + def find_our_next_snapshot(self, snapshot): + """find our 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.our_snapshots.index(snapshot) + if index>=0 and index