mirror of
https://github.com/psy0rz/zfs_autobackup.git
synced 2025-05-30 01:19:16 +03:00
wip fixes
This commit is contained in:
parent
0ec493d231
commit
231a390818
@ -190,7 +190,7 @@ test_target1/test_source2/fs2/sub@test-20101111000003
|
|||||||
with mocktime("20101111000001"):
|
with mocktime("20101111000001"):
|
||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
ZfsAutobackup(
|
ZfsAutobackup(
|
||||||
"test test_target1/a --no-progress --verbose --allow-empty --tag tag1".split(" ")).run())
|
"test test_target1/a --no-progress --verbose --allow-empty --debug --tag tag1".split(" ")).run())
|
||||||
|
|
||||||
# increment, should be from bookmark
|
# increment, should be from bookmark
|
||||||
with mocktime("20101111000002"):
|
with mocktime("20101111000002"):
|
||||||
|
@ -224,7 +224,7 @@ class ZfsAutobackup(ZfsAuto):
|
|||||||
# does it have other snapshots?
|
# does it have other snapshots?
|
||||||
has_others = False
|
has_others = False
|
||||||
for snapshot in dataset.snapshots:
|
for snapshot in dataset.snapshots:
|
||||||
if not snapshot.is_ours():
|
if not snapshot.is_ours:
|
||||||
has_others = True
|
has_others = True
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -62,6 +62,8 @@ class ZfsDataset:
|
|||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def __eq__(self, dataset):
|
def __eq__(self, dataset):
|
||||||
|
"""compare the full name of the dataset"""
|
||||||
|
|
||||||
if not isinstance(dataset, ZfsDataset):
|
if not isinstance(dataset, ZfsDataset):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -145,10 +147,10 @@ class ZfsDataset:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def tagless_suffix(self):
|
def tagless_suffix(self):
|
||||||
"""snapshot or bookmark part of the name, but without the tag."""
|
"""snapshot or bookmark part of the name, but without the tag. (if its our snapshot we remove the tag)"""
|
||||||
|
|
||||||
suffix = self.suffix
|
suffix = self.suffix
|
||||||
if self.zfs_node.tag_seperator in suffix:
|
if self.is_ours and self.zfs_node.tag_seperator in suffix:
|
||||||
return suffix.split(self.zfs_node.tag_seperator)[0]
|
return suffix.split(self.zfs_node.tag_seperator)[0]
|
||||||
else:
|
else:
|
||||||
return suffix
|
return suffix
|
||||||
@ -286,6 +288,8 @@ class ZfsDataset:
|
|||||||
def find_next_snapshot(self, snapshot_bookmark):
|
def find_next_snapshot(self, snapshot_bookmark):
|
||||||
"""find next snapshot in this dataset, according to snapshot or bookmark. None if it doesn't exist
|
"""find next snapshot in this dataset, according to snapshot or bookmark. None if it doesn't exist
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
:type snapshot_bookmark: ZfsDataset
|
:type snapshot_bookmark: ZfsDataset
|
||||||
"""
|
"""
|
||||||
@ -298,7 +302,7 @@ class ZfsDataset:
|
|||||||
if snapshot == snapshot_bookmark:
|
if snapshot == snapshot_bookmark:
|
||||||
found = True
|
found = True
|
||||||
else:
|
else:
|
||||||
if found == True and snapshot.is_snapshot:
|
if found and snapshot.is_snapshot:
|
||||||
return snapshot
|
return snapshot
|
||||||
|
|
||||||
return None
|
return None
|
||||||
@ -417,6 +421,7 @@ class ZfsDataset:
|
|||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@property
|
||||||
def is_ours(self):
|
def is_ours(self):
|
||||||
"""return true if this snapshot name belong to the current backup_name and snapshot formatting"""
|
"""return true if this snapshot name belong to the current backup_name and snapshot formatting"""
|
||||||
return self.timestamp is not None
|
return self.timestamp is not None
|
||||||
@ -454,8 +459,13 @@ class ZfsDataset:
|
|||||||
:rtype: int|None
|
:rtype: int|None
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if self.zfs_node.tag_seperator in self.suffix:
|
||||||
|
tagless_suffix = self.suffix.split(self.zfs_node.tag_seperator)[0]
|
||||||
|
else:
|
||||||
|
tagless_suffix = self.suffix
|
||||||
|
|
||||||
try:
|
try:
|
||||||
dt = datetime.strptime(self.tagless_suffix, self.zfs_node.snapshot_time_format)
|
dt = datetime.strptime(tagless_suffix, self.zfs_node.snapshot_time_format)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -526,7 +536,7 @@ class ZfsDataset:
|
|||||||
ret = []
|
ret = []
|
||||||
|
|
||||||
for snapshot in self.snapshots:
|
for snapshot in self.snapshots:
|
||||||
if snapshot.is_ours():
|
if snapshot.is_ours:
|
||||||
ret.append(snapshot)
|
ret.append(snapshot)
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
@ -548,6 +558,8 @@ class ZfsDataset:
|
|||||||
"""find snapshot by snapshot name (can be a suffix or a different
|
"""find snapshot by snapshot name (can be a suffix or a different
|
||||||
ZfsDataset) Returns None if it cant find it.
|
ZfsDataset) Returns None if it cant find it.
|
||||||
|
|
||||||
|
Note that matches with our own snapshots will be done tagless.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
:rtype: ZfsDataset|None
|
:rtype: ZfsDataset|None
|
||||||
:type snapshot: str|ZfsDataset|None
|
:type snapshot: str|ZfsDataset|None
|
||||||
@ -1206,7 +1218,7 @@ class ZfsDataset:
|
|||||||
|
|
||||||
while source_snapshot:
|
while source_snapshot:
|
||||||
# we want it?
|
# we want it?
|
||||||
if (also_other_snapshots or source_snapshot.is_ours()) and not source_snapshot.is_snapshot_excluded:
|
if (also_other_snapshots or source_snapshot.is_ours) and not source_snapshot.is_snapshot_excluded:
|
||||||
# create virtual target snapshot
|
# create virtual target snapshot
|
||||||
target_snapshot = target_dataset.zfs_node.get_dataset(
|
target_snapshot = target_dataset.zfs_node.get_dataset(
|
||||||
target_dataset.filesystem_name + source_snapshot.typed_suffix, force_exists=False)
|
target_dataset.filesystem_name + source_snapshot.typed_suffix, force_exists=False)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user