From ad0785f3eb1760c1b4331af5c63df1d3a745a988 Mon Sep 17 00:00:00 2001 From: Orsiris de Jong Date: Mon, 15 Jan 2024 16:38:10 +0100 Subject: [PATCH] Various JS / backend binary fixes --- npbackup/core/runner.py | 18 ++++++++++-------- npbackup/restic_wrapper/__init__.py | 7 +++++-- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/npbackup/core/runner.py b/npbackup/core/runner.py index 11f4a50..d5b1879 100644 --- a/npbackup/core/runner.py +++ b/npbackup/core/runner.py @@ -139,8 +139,6 @@ class NPBackupRunner: self.minimum_backup_age = None self._exec_time = None - self._using_dev_binary = False - @property def repo_config(self) -> dict: return self._repo_config @@ -556,11 +554,11 @@ class NPBackupRunner: arch = os_arch() binary = get_restic_internal_binary(arch) if binary: - if not self._using_dev_binary: - self._using_dev_binary = True - self.write_logs("Using dev binary !", level="info") self.restic_runner.binary = binary + version = self.restic_runner.binary_version + self.write_logs(f"Using dev binary {version}", level="info") else: + self._is_ready = False return False return True @@ -684,9 +682,12 @@ class NPBackupRunner: if self.json_output: if backend_js: js = backend_js - js = { - "result": result, - } + if isinstance(result, dict): + js = result + else: + js = { + "result": result, + } if warnings: js["warnings"] = warnings if result: @@ -1017,6 +1018,7 @@ class NPBackupRunner: self.write_logs(f"Restic output:\n{self.restic_runner.backup_result_content}", level="debug") # Extract backup size from result_string + # Metrics will not be in json format, since we need to diag cloud issues until metrics_analyzer_result = metric_writer( self.repo_config, result, self.restic_runner.backup_result_content, self.restic_runner.dry_run ) diff --git a/npbackup/restic_wrapper/__init__.py b/npbackup/restic_wrapper/__init__.py index fb7b186..2ba0e6f 100644 --- a/npbackup/restic_wrapper/__init__.py +++ b/npbackup/restic_wrapper/__init__.py @@ -318,6 +318,7 @@ class ResticRunner: ): is_cloud_error = False if is_cloud_error is True: + self.last_command_status = True return True, output else: self.write_logs("Some files could not be backed up", level="error") @@ -785,7 +786,9 @@ class ResticRunner: if additional_backup_only_parameters: cmd += " {}".format(additional_backup_only_parameters) - # Run backup + # Run backup without json output, as we could not compute the cloud errors in json output via regexes + json_output = self.json_output + self.json_output = False if read_from_stdin: result, output = self.executor(cmd, stdin=sys.stdin.buffer) else: @@ -800,7 +803,7 @@ class ResticRunner: "VSS cannot be used. Backup will be done without VSS.", level="error" ) result, output = self.executor(cmd.replace(" --use-fs-snapshot", "")) - + self.json_output = json_output if result: msg = "Backend finished backup with success" else: