add: steps towards sending first snapshot

This commit is contained in:
timeshifter
2021-12-04 14:59:58 +01:00
parent 6cd61f8709
commit f070a35937
+18 -6
View File
@@ -75,13 +75,25 @@ class Manager:
remote_dataset = self._search_matching_dataset_in_remote_pool(
local_dataset, self._external_pool
)
start_snapshot = self._get_last_common_snapshot(
local_dataset, remote_dataset
)
end_snapshot = self._get_last_snapshot_with_backup_tag(local_dataset)
stream = ZFS.send_incremental(start_snapshot, end_snapshot)
if remote_dataset:
stream = self._send_incremental(local_dataset, remote_dataset)
else:
# TODO ask for confirmation before sending
stream = self._send_absolute(local_dataset)
ZFS.receive(stream, self._external_pool)
def _send_incremental(self, local_dataset: Dataset, remote_dataset: Dataset) -> Popen:
start_snapshot = self._get_last_common_snapshot(
local_dataset, remote_dataset
)
end_snapshot = self._get_last_snapshot_with_backup_tag(local_dataset)
stream = ZFS.send_incremental(start_snapshot, end_snapshot)
return stream
def _send_absolute(self, local_dataset: Dataset) -> Popen:
snapshot = self._get_last_snapshot_with_backup_tag(local_dataset)
return ZFS.send_absolute(snapshot)
def _get_last_snapshot_with_backup_tag(self, local_dataset):
snapshots = self._find_snapshots_with_backup_tag(local_dataset)
snapshots.sort()
@@ -106,7 +118,7 @@ class Manager:
]
@staticmethod
def _search_matching_dataset_in_remote_pool(dataset: Dataset, pool: Pool):
def _search_matching_dataset_in_remote_pool(dataset: Dataset, pool: Pool) -> Dataset | None:
dataset_to_search = dataset.replace_pool(pool.name)
for dataset in pool.datasets:
if dataset == dataset_to_search: