error print, backup_check fix

This commit is contained in:
ROTTLER Tamas 2023-03-04 02:59:55 +01:00
parent 4936a2088f
commit 7961bb6ce7
2 changed files with 4 additions and 3 deletions

View File

@ -51,7 +51,7 @@ def main():
else:
agetext = f'{age:.1f}h'
backuptimestamp = datetime.datetime.fromtimestamp(backuptime).strftime('%F %H:%M:%S')
if age > args.maxage:
if age > maxage:
print(f'WARNING: {args.host}: last backup {backuptimestamp}, {agetext} ago (>{maxage}h)')
exit(1)
if args.verbose:

View File

@ -259,8 +259,9 @@ class RouterosConfig(Config):
iproute.append(line)
stdin, stdout, stderr = self.ssh.exec_command('/system backup save dont-encrypt=yes name=autobck')
if not re.search('Configuration backup saved', str(stdout.read(), 'utf8')):
raise RuntimeError('"/system backup" failed')
output = str(stdout.read(), 'utf8')
if not re.search('Configuration backup saved', output):
raise RuntimeError(f'"/system backup" failed: {output.strip()}')
sftp = self.ssh.open_sftp()
with sftp.open('autobck.backup', 'r') as sf: