diff --git a/backup/views.py b/backup/views.py index 6ba514f61..7689ef1ac 100755 --- a/backup/views.py +++ b/backup/views.py @@ -421,9 +421,15 @@ def localInitiate(request): data = json.loads(request.body) randomFile = data['randomFile'] - if os.path.exists(randomFile): - wm = BackupManager() - return wm.submitBackupCreation(1, json.loads(request.body)) + try: + randInt = int(randomFile) + pathToFile = "/home/cyberpanel/" + randomFile + + if os.path.exists(pathToFile): + wm = BackupManager() + return wm.submitBackupCreation(1, json.loads(request.body)) + except: + pass except BaseException as msg: logging.writeToFile(str(msg)) diff --git a/plogical/backupSchedule.py b/plogical/backupSchedule.py index 92f74961f..c803208ab 100755 --- a/plogical/backupSchedule.py +++ b/plogical/backupSchedule.py @@ -52,14 +52,14 @@ def createLocalBackup(virtualHost, backupLogPath): backupSchedule.remoteBackupLogging(backupLogPath, "Starting local backup for: " + virtualHost) ### - - pathToFile = "/home/cyberpanel/" + str(randint(10**9, 10**10 - 1)) + randNBR = str(randint(10**9, 10**10 - 1)) + pathToFile = "/home/cyberpanel/" + randNBR file = open(pathToFile, "w+") file.close() port = ProcessUtilities.fetchCurrentPort() - finalData = json.dumps({'randomFile': pathToFile, 'websiteToBeBacked': virtualHost}) + finalData = json.dumps({'randomFile': randNBR, 'websiteToBeBacked': virtualHost}) r = requests.post("https://localhost:%s/backup/localInitiate" % (port), data=finalData, verify=False) if os.path.exists(ProcessUtilities.debugPath):