diff --git a/backup/backupManager.py b/backup/backupManager.py index 33ae9b06d..a507412a4 100644 --- a/backup/backupManager.py +++ b/backup/backupManager.py @@ -181,19 +181,23 @@ class BackupManager: if status.find("Completed") > -1: - backupOb = Backups.objects.get(fileName=fileName) - backupOb.status = 1 + backupObs = Backups.objects.filter(fileName=fileName) ## adding backup data to database. try: - backupOb.size = str(int(float( - os.path.getsize("/home/" + backupDomain + "/backup/" + fileName + ".tar.gz")) / ( - 1024.0 * 1024.0))) + "MB" - backupOb.save() + for items in backupObs: + items.status = 1 + items.size = str(int(float( + os.path.getsize("/home/" + backupDomain + "/backup/" + fileName + ".tar.gz")) / ( + 1024.0 * 1024.0))) + "MB" + items.save() except: - backupOb.size = str( - int(os.path.getsize("/home/" + backupDomain + "/backup/" + fileName + ".tar.gz"))) - backupOb.save() + for items in backupObs: + items.status = 1 + items.size = str(int(float( + os.path.getsize("/home/" + backupDomain + "/backup/" + fileName + ".tar.gz")) / ( + 1024.0 * 1024.0))) + "MB" + items.save() ### Removing Files diff --git a/plogical/backupSchedule.py b/plogical/backupSchedule.py index 22679de33..c010124ee 100644 --- a/plogical/backupSchedule.py +++ b/plogical/backupSchedule.py @@ -49,6 +49,7 @@ class backupSchedule: except BaseException, msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]") + return 0, "None" @staticmethod def createBackup(virtualHost, ipAddress, backupLogPath , port): @@ -147,20 +148,22 @@ class backupSchedule: ipAddressLocal = ipData.split('\n', 1)[0] - if backupUtilities.checkIfHostIsUp(ipAddress) == 1: - checkConn = backupUtilities.checkConnection(ipAddress) - if checkConn[0] == 0: - backupSchedule.remoteBackupLogging(backupLogPath, "Connection to: " + ipAddress+ " Failed, please resetup this destination from CyberPanel, aborting.") - return 0 - else: - ## Create backup dir on remote server + if backupUtilities.checkIfHostIsUp(ipAddress) != 1: + backupSchedule.remoteBackupLogging(backupLogPath, "Ping for : " + ipAddress + " does not seems to work, however we will continue.") - command = "sudo ssh -o StrictHostKeyChecking=no -p " + port + " -i /root/.ssh/cyberpanel root@" + ipAddress + " mkdir -p /home/backup/"+ ipAddressLocal + "/" + time.strftime("%a-%b") - subprocess.call(shlex.split(command)) - pass - else: - backupSchedule.remoteBackupLogging(backupLogPath, "Host: " + ipAddress + " is down, aborting.") + + checkConn = backupUtilities.checkConnection(ipAddress) + if checkConn[0] == 0: + backupSchedule.remoteBackupLogging(backupLogPath, + "Connection to: " + ipAddress + " Failed, please resetup this destination from CyberPanel, aborting.") return 0 + else: + ## Create backup dir on remote server + + command = "sudo ssh -o StrictHostKeyChecking=no -p " + port + " -i /root/.ssh/cyberpanel root@" + ipAddress + " mkdir -p /home/backup/" + ipAddressLocal + "/" + time.strftime( + "%a-%b") + subprocess.call(shlex.split(command)) + pass for virtualHost in os.listdir("/home"): if match(r'([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?', virtualHost, M | I): diff --git a/plogical/backupUtilities.py b/plogical/backupUtilities.py index d37f3a5d3..318cbfd8d 100644 --- a/plogical/backupUtilities.py +++ b/plogical/backupUtilities.py @@ -541,7 +541,7 @@ class backupUtilities: if os.path.exists(sslStoragePath): sslHome = '/etc/letsencrypt/live/' + domain - + try: if not os.path.exists(sslHome): os.mkdir(sslHome)