mirror of
https://github.com/netinvent/npbackup.git
synced 2024-09-21 15:26:24 +08:00
Fix has_recent_snapshot output without json
This commit is contained in:
parent
b8c75b35d3
commit
fca5343f52
|
@ -782,18 +782,16 @@ class NPBackupRunner:
|
||||||
)
|
)
|
||||||
# Temporarily disable verbose and enable json result
|
# Temporarily disable verbose and enable json result
|
||||||
self.restic_runner.verbose = False
|
self.restic_runner.verbose = False
|
||||||
json_output = self.restic_runner.json_output
|
|
||||||
self.restic_runner.json_output = True
|
|
||||||
data = self.restic_runner.has_recent_snapshot(
|
data = self.restic_runner.has_recent_snapshot(
|
||||||
self.minimum_backup_age
|
self.minimum_backup_age
|
||||||
)
|
)
|
||||||
self.restic_runner.verbose = self.verbose
|
self.restic_runner.verbose = self.verbose
|
||||||
self.restic_runner.json_output = json_output
|
|
||||||
if self.json_output:
|
if self.json_output:
|
||||||
return data
|
return data
|
||||||
|
|
||||||
result = data["result"]
|
# has_recent_snapshot returns a tuple when not self.json_output
|
||||||
backup_tz = data["output"]
|
result = data[0]
|
||||||
|
backup_tz = data[1]
|
||||||
if result:
|
if result:
|
||||||
self.write_logs(
|
self.write_logs(
|
||||||
f"Most recent backup in repo {self.repo_config.g('name')} is from {backup_tz}",
|
f"Most recent backup in repo {self.repo_config.g('name')} is from {backup_tz}",
|
||||||
|
|
|
@ -1074,8 +1074,10 @@ class ResticRunner:
|
||||||
return False, None
|
return False, None
|
||||||
try:
|
try:
|
||||||
# Make sure we run with json support for this one
|
# Make sure we run with json support for this one
|
||||||
|
json_output = self.json_output
|
||||||
|
self.json_output = True
|
||||||
result = self.snapshots()
|
result = self.snapshots()
|
||||||
|
self.json_output = json_output
|
||||||
if self.last_command_status is False:
|
if self.last_command_status is False:
|
||||||
if self.json_output:
|
if self.json_output:
|
||||||
msg = "Could not check for snapshots"
|
msg = "Could not check for snapshots"
|
||||||
|
|
Loading…
Reference in a new issue