add: first backup feature
This commit is contained in:
+17
-3
@@ -47,7 +47,6 @@ def main():
|
|||||||
|
|
||||||
# TODO tests
|
# TODO tests
|
||||||
# TODO docstrings
|
# TODO docstrings
|
||||||
# TODO first backup
|
|
||||||
# TODO --skip-import
|
# TODO --skip-import
|
||||||
# TODO --skip-post-backup-scrub
|
# TODO --skip-post-backup-scrub
|
||||||
# TODO print time estimation while scrub is in progress
|
# TODO print time estimation while scrub is in progress
|
||||||
@@ -78,8 +77,10 @@ class Manager:
|
|||||||
if remote_dataset:
|
if remote_dataset:
|
||||||
stream = self._send_incremental(local_dataset, remote_dataset)
|
stream = self._send_incremental(local_dataset, remote_dataset)
|
||||||
else:
|
else:
|
||||||
# TODO ask for confirmation before sending
|
if self._ask_user_confirmation(local_dataset):
|
||||||
stream = self._send_absolute(local_dataset)
|
stream = self._send_absolute(local_dataset)
|
||||||
|
else:
|
||||||
|
continue
|
||||||
ZFS.receive(stream, self._external_pool)
|
ZFS.receive(stream, self._external_pool)
|
||||||
|
|
||||||
def _send_incremental(
|
def _send_incremental(
|
||||||
@@ -139,6 +140,19 @@ class Manager:
|
|||||||
common_snapshots.sort()
|
common_snapshots.sort()
|
||||||
return common_snapshots[-1]
|
return common_snapshots[-1]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _ask_user_confirmation(dataset: Dataset) -> bool:
|
||||||
|
msg = f"Dataset {dataset.qualified_name} does not exist in backup pool. Backup? [y/n] "
|
||||||
|
reply = ""
|
||||||
|
while not reply:
|
||||||
|
reply = input(msg).lower()
|
||||||
|
if reply == "y":
|
||||||
|
return True
|
||||||
|
elif reply == "n":
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
reply = ""
|
||||||
|
|
||||||
|
|
||||||
def _get_regex_matching_snapshots_with_tags(tags: list[str]):
|
def _get_regex_matching_snapshots_with_tags(tags: list[str]):
|
||||||
return "@" + ".*".join(tags)
|
return "@" + ".*".join(tags)
|
||||||
|
|||||||
Reference in New Issue
Block a user