add: first backup feature

This commit is contained in:
timeshifter
2021-12-04 21:04:53 +01:00
parent 5ab603ed60
commit 5fd53479a0
+16 -2
View File
@@ -47,7 +47,6 @@ def main():
# TODO tests
# TODO docstrings
# TODO first backup
# TODO --skip-import
# TODO --skip-post-backup-scrub
# TODO print time estimation while scrub is in progress
@@ -78,8 +77,10 @@ class Manager:
if remote_dataset:
stream = self._send_incremental(local_dataset, remote_dataset)
else:
# TODO ask for confirmation before sending
if self._ask_user_confirmation(local_dataset):
stream = self._send_absolute(local_dataset)
else:
continue
ZFS.receive(stream, self._external_pool)
def _send_incremental(
@@ -139,6 +140,19 @@ class Manager:
common_snapshots.sort()
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]):
return "@" + ".*".join(tags)