From c0c3cb78b4182a9d93b52b40d24c6869ff46457e Mon Sep 17 00:00:00 2001 From: deajan Date: Tue, 11 Jun 2024 22:18:50 +0200 Subject: [PATCH] Don't check for recent backup if --force is goven --- npbackup/core/runner.py | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/npbackup/core/runner.py b/npbackup/core/runner.py index 165773b..f3275fd 100644 --- a/npbackup/core/runner.py +++ b/npbackup/core/runner.py @@ -1076,23 +1076,24 @@ class NPBackupRunner: "backup_opts.additional_backup_only_parameters" ) - # Check if backup is required, no need to be verbose, but we'll make sure we don't get a json result here - self.restic_runner.verbose = False - json_output = self.json_output - self.json_output = False - # Since we don't want to close queues nor create a subthread, we need to change behavior here - # pylint: disable=E1123 (unexpected-keyword-arg) - has_recent_snapshots, backup_tz = self.has_recent_snapshot( - __close_queues=False, __no_threads=True - ) - self.json_output = json_output - # We also need to "reapply" the json setting to backend - self.restic_runner.json_output = json_output - if has_recent_snapshots and not force: - msg = "No backup necessary" - self.write_logs(msg, level="info") - return self.convert_to_json_output(True, msg) - self.restic_runner.verbose = self.verbose + if not force: + # Check if backup is required, no need to be verbose, but we'll make sure we don't get a json result here + self.restic_runner.verbose = False + json_output = self.json_output + self.json_output = False + # Since we don't want to close queues nor create a subthread, we need to change behavior here + # pylint: disable=E1123 (unexpected-keyword-arg) + has_recent_snapshots, _ = self.has_recent_snapshot( + __close_queues=False, __no_threads=True + ) + self.json_output = json_output + # We also need to "reapply" the json setting to backend + self.restic_runner.json_output = json_output + if has_recent_snapshots: + msg = "No backup necessary" + self.write_logs(msg, level="info") + return self.convert_to_json_output(True, msg) + self.restic_runner.verbose = self.verbose # Run backup here if not read_from_stdin: