From 7961bb6ce73be69846965b55063be09ab017b975 Mon Sep 17 00:00:00 2001 From: Rottler Tamas Date: Sat, 4 Mar 2023 02:59:55 +0100 Subject: [PATCH] error print, backup_check fix --- backup_check | 2 +- routerbackup | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/backup_check b/backup_check index 7ae0823..4b116da 100755 --- a/backup_check +++ b/backup_check @@ -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: diff --git a/routerbackup b/routerbackup index 4ba5a7a..e98813c 100755 --- a/routerbackup +++ b/routerbackup @@ -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: