From 6769e83aa189aab6ffa692a22541c75901263a68 Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Fri, 29 May 2020 23:39:41 +0500 Subject: [PATCH] fix job success calculator --- install/firewallUtilities.py | 4 +++- plogical/backupSchedule.py | 10 +++++++++- plogical/backupScheduleLocal.py | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/install/firewallUtilities.py b/install/firewallUtilities.py index 92e4b6a81..e3a97d330 100755 --- a/install/firewallUtilities.py +++ b/install/firewallUtilities.py @@ -25,6 +25,9 @@ class FirewallUtilities: @staticmethod def addRule(proto,port): + + print('Adding port: %s' % (port)) + if port == "21": command = "sudo firewall-cmd --add-service=ftp --permanent" else: @@ -56,7 +59,6 @@ class FirewallUtilities: @staticmethod def deleteRule(proto, port): - print('Adding port: %s' % (port)) if port=="21": command = "sudo firewall-cmd --remove-service=ftp --permanent" diff --git a/plogical/backupSchedule.py b/plogical/backupSchedule.py index 46f531eab..75c440e75 100755 --- a/plogical/backupSchedule.py +++ b/plogical/backupSchedule.py @@ -216,6 +216,7 @@ class backupSchedule: backupSchedule.remoteBackupLogging(backupLogPath, "") backupSchedule.remoteBackupLogging(backupLogPath, "") + return 1 else: backupSchedule.remoteBackupLogging(backupLogPath, 'Remote backup creation failed for %s.' % (virtualHost) ) @@ -227,6 +228,7 @@ class backupSchedule: backupSchedule.remoteBackupLogging(backupLogPath, "") backupSchedule.remoteBackupLogging(backupLogPath, "") + return 0 except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [backupSchedule.createBackup]") @@ -332,8 +334,14 @@ class backupSchedule: for virtualHost in os.listdir("/home"): if match(r'^[a-zA-Z0-9-]*[a-zA-Z0-9-]{0,61}[a-zA-Z0-9-](?:\.[a-zA-Z0-9-]{2,})+$', virtualHost, M | I): - backupSchedule.createBackup(virtualHost, ipAddress, backupLogPath, port, user) + if backupSchedule.createBackup(virtualHost, ipAddress, backupLogPath, port, user): + jobSuccessSites = jobSuccessSites + 1 + else: + jobFailedSites = jobFailedSites + 1 + backupSchedule.backupLog.jobFailedSites = jobFailedSites + backupSchedule.backupLog.jobSuccessSites = jobSuccessSites + backupSchedule.backupLog.save() backupSchedule.remoteBackupLogging(backupLogPath, "Remote backup job completed.\n") diff --git a/plogical/backupScheduleLocal.py b/plogical/backupScheduleLocal.py index 6065b9c92..b233d8789 100755 --- a/plogical/backupScheduleLocal.py +++ b/plogical/backupScheduleLocal.py @@ -62,6 +62,7 @@ class backupScheduleLocal: if retValues[0] == 0: backupSchedule.remoteBackupLogging(backupLogPath, '[ERROR] Backup failed for %s, error: %s moving on..' % (virtualHost, retValues[1]), backupSchedule.ERROR) + jobFailedSites = jobFailedSites + 1 continue if os.path.exists(backupScheduleLocal.localBackupPath):