add: steps towards sending first snapshot
This commit is contained in:
+14
-2
@@ -75,12 +75,24 @@ class Manager:
|
||||
remote_dataset = self._search_matching_dataset_in_remote_pool(
|
||||
local_dataset, self._external_pool
|
||||
)
|
||||
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)
|
||||
ZFS.receive(stream, self._external_pool)
|
||||
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)
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user