Skip to content
Permalink
Browse files
fix job success calculator
  • Loading branch information
usmannasir committed May 29, 2020
1 parent 7ef5fac commit 6769e83aa189aab6ffa692a22541c75901263a68
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
@@ -25,6 +25,9 @@ def doCommand(command):

@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 @@ def addRule(proto,port):

@staticmethod
def deleteRule(proto, port):
print('Adding port: %s' % (port))

if port=="21":
command = "sudo firewall-cmd --remove-service=ftp --permanent"
@@ -216,6 +216,7 @@ def createBackup(virtualHost, ipAddress, backupLogPath , port='22', user='root')

backupSchedule.remoteBackupLogging(backupLogPath, "")
backupSchedule.remoteBackupLogging(backupLogPath, "")
return 1
else:

backupSchedule.remoteBackupLogging(backupLogPath, 'Remote backup creation failed for %s.' % (virtualHost) )
@@ -227,6 +228,7 @@ def createBackup(virtualHost, ipAddress, backupLogPath , port='22', user='root')

backupSchedule.remoteBackupLogging(backupLogPath, "")
backupSchedule.remoteBackupLogging(backupLogPath, "")
return 0

except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [backupSchedule.createBackup]")
@@ -332,8 +334,14 @@ def prepare():

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")

@@ -62,6 +62,7 @@ def prepare():

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):

0 comments on commit 6769e83

Please sign in to comment.