From 891f6f3eec0ba0b5184f4a05178e9e032882fafd Mon Sep 17 00:00:00 2001 From: timeshifter Date: Tue, 6 Dec 2022 14:28:33 +0100 Subject: [PATCH] small refactor --- zfs_backup.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/zfs_backup.py b/zfs_backup.py index f7ed8fd..136d1df 100755 --- a/zfs_backup.py +++ b/zfs_backup.py @@ -99,7 +99,7 @@ class Manager: def _send_incremental( self, local_dataset: Dataset, remote_dataset: Dataset ) -> Popen | None: - """Send incremental stream between two datasets to remote.""" + """Send incremental stream between two datasets to remote, return the pipe. If local and remote snapshot are identical, perform nothing and return None.""" start_snapshot = self._get_newest_common_snapshot_with_backup_tags( local_dataset, remote_dataset ) @@ -118,8 +118,7 @@ class Manager: """From all snapshots in the dataset, get the newest one that matches the backup tags in the config.""" snapshots = self._find_snapshots_with_backup_tag(dataset) snapshots.sort() - end_snapshot = snapshots[-1] - return end_snapshot + return snapshots[-1] @property def _datasets_to_backup(self) -> list[Dataset]: @@ -848,4 +847,8 @@ def _verify_running_as_root() -> None: if __name__ == "__main__": - main() + try: + main() + except Exception as e: + print(e) + exit(EXIT_ERROR)