mirror of
https://github.com/psy0rz/zfs_autobackup.git
synced 2025-06-09 01:52:07 +03:00
fixes
This commit is contained in:
parent
cf541c581c
commit
4fbcc87558
@ -597,6 +597,7 @@ class ZfsDataset:
|
|||||||
ZfsDataset) Returns None if it cant find it.
|
ZfsDataset) Returns None if it cant find it.
|
||||||
|
|
||||||
We try to find the bookmark with the preferred tag (which is usually a target path guid, to prevent conflicting bookmarks by multiple sends)
|
We try to find the bookmark with the preferred tag (which is usually a target path guid, to prevent conflicting bookmarks by multiple sends)
|
||||||
|
After that we return any bookmark that matches (and ignore the tag)
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
:rtype: ZfsDataset|None
|
:rtype: ZfsDataset|None
|
||||||
@ -622,6 +623,17 @@ class ZfsDataset:
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def find_exact_bookmark(self, bookmark_name):
|
||||||
|
"""find exact bookmark name, or retruns none
|
||||||
|
|
||||||
|
:rtype: ZfsDataset|None
|
||||||
|
"""
|
||||||
|
|
||||||
|
for snapshot_bookmark in self.bookmarks:
|
||||||
|
if snapshot_bookmark.name == bookmark_name:
|
||||||
|
return snapshot_bookmark
|
||||||
|
return None
|
||||||
|
|
||||||
def find_snapshot_index(self, snapshot):
|
def find_snapshot_index(self, snapshot):
|
||||||
"""find snapshot index by snapshot (can be a snapshot_name or
|
"""find snapshot index by snapshot (can be a snapshot_name or
|
||||||
ZfsDataset)
|
ZfsDataset)
|
||||||
@ -679,15 +691,21 @@ class ZfsDataset:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def bookmark(self, tag):
|
def bookmark(self, tag):
|
||||||
"""Bookmark this snapshot, and return the bookmark."""
|
"""Bookmark this snapshot, and return the bookmark. If the bookmark already exist, it returns it."""
|
||||||
# NOTE: we use the tag to add the target_path GUID, so that we can have multiple bookmarks for the same snapshot, but for different target. This is to make sure you can send a backup to two locations, without them interfering with eachothers bookmarks.
|
# NOTE: we use the tag to add the target_path GUID, so that we can have multiple bookmarks for the same snapshot, but for different target. This is to make sure you can send a backup to two locations, without them interfering with eachothers bookmarks.
|
||||||
|
|
||||||
if not self.is_snapshot:
|
if not self.is_snapshot:
|
||||||
raise (Exception("Can only bookmark a snapshot!"))
|
raise (Exception("Can only bookmark a snapshot!"))
|
||||||
|
|
||||||
self.debug("Bookmarking")
|
|
||||||
|
|
||||||
bookmark_name = self.prefix + "#" + self.tagless_suffix + self.zfs_node.tag_seperator + tag
|
bookmark_name = self.prefix + "#" + self.tagless_suffix + self.zfs_node.tag_seperator + tag
|
||||||
|
|
||||||
|
# does this exact bookmark (including tag) already exists?
|
||||||
|
existing_bookmark = self.find_exact_bookmark(bookmark_name)
|
||||||
|
if existing_bookmark is not None:
|
||||||
|
return existing_bookmark
|
||||||
|
|
||||||
|
self.debug("Bookmarking {}".format(bookmark_name))
|
||||||
|
|
||||||
cmd = [
|
cmd = [
|
||||||
"zfs", "bookmark", self.name, bookmark_name
|
"zfs", "bookmark", self.name, bookmark_name
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user