mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-10-30 18:06:35 +01:00
bug fix to remote backups
This commit is contained in:
@@ -19,19 +19,20 @@ class backupSchedule:
|
|||||||
except IOError,msg:
|
except IOError,msg:
|
||||||
return "Can not write to error file."
|
return "Can not write to error file."
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def createBackup(virtualHost, ipAddress, backupLogPath , port):
|
def createLocalBackup(virtualHost, backupLogPath):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
backupSchedule.remoteBackupLogging(backupLogPath, "Preparing to create backup for: " + virtualHost)
|
backupSchedule.remoteBackupLogging(backupLogPath, "Starting local backup for: " + virtualHost)
|
||||||
backupSchedule.remoteBackupLogging(backupLogPath, "Backup started for: " + virtualHost)
|
|
||||||
|
|
||||||
finalData = json.dumps({'websiteToBeBacked': virtualHost})
|
finalData = json.dumps({'websiteToBeBacked': virtualHost})
|
||||||
r = requests.post("http://localhost:5003/backup/submitBackupCreation", data=finalData)
|
r = requests.post("http://localhost:5003/backup/submitBackupCreation", data=finalData)
|
||||||
|
|
||||||
data = json.loads(r.text)
|
data = json.loads(r.text)
|
||||||
backupPath = data['tempStorage']
|
backupPath = data['tempStorage']
|
||||||
|
|
||||||
|
backupSchedule.remoteBackupLogging(backupLogPath, "Waiting for backup to complete.. ")
|
||||||
|
|
||||||
|
|
||||||
while (1):
|
while (1):
|
||||||
r = requests.post("http://localhost:5003/backup/backupStatus", data=finalData)
|
r = requests.post("http://localhost:5003/backup/backupStatus", data=finalData)
|
||||||
@@ -39,9 +40,27 @@ class backupSchedule:
|
|||||||
data = json.loads(r.text)
|
data = json.loads(r.text)
|
||||||
|
|
||||||
if data['backupStatus'] == 0:
|
if data['backupStatus'] == 0:
|
||||||
break
|
backupSchedule.remoteBackupLogging(backupLogPath, "An error occurred, Error message: " + data[
|
||||||
|
'error_message'])
|
||||||
|
return 0, backupPath
|
||||||
elif data['abort'] == 1:
|
elif data['abort'] == 1:
|
||||||
break
|
backupSchedule.remoteBackupLogging(backupLogPath, "Backup Completed for: " + virtualHost)
|
||||||
|
return 1, backupPath
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]")
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def createBackup(virtualHost, ipAddress, backupLogPath , port):
|
||||||
|
try:
|
||||||
|
|
||||||
|
backupSchedule.remoteBackupLogging(backupLogPath, "Preparing to create backup for: " + virtualHost)
|
||||||
|
backupSchedule.remoteBackupLogging(backupLogPath, "Backup started for: " + virtualHost)
|
||||||
|
|
||||||
|
retValues = backupSchedule.createLocalBackup(virtualHost, backupLogPath)
|
||||||
|
|
||||||
|
if retValues[0] == 1:
|
||||||
|
backupPath = retValues[1]
|
||||||
|
|
||||||
backupSchedule.remoteBackupLogging(backupLogPath, "Backup created for: " + virtualHost)
|
backupSchedule.remoteBackupLogging(backupLogPath, "Backup created for: " + virtualHost)
|
||||||
|
|
||||||
@@ -56,6 +75,15 @@ class backupSchedule:
|
|||||||
## Backup sent.
|
## Backup sent.
|
||||||
|
|
||||||
|
|
||||||
|
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||||
|
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||||
|
|
||||||
|
backupSchedule.remoteBackupLogging(backupLogPath, "#################################################")
|
||||||
|
|
||||||
|
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||||
|
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||||
|
else:
|
||||||
|
|
||||||
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||||
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||||
|
|
||||||
@@ -138,6 +166,11 @@ class backupSchedule:
|
|||||||
if match(r'([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?', virtualHost, M | I):
|
if match(r'([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?', virtualHost, M | I):
|
||||||
backupSchedule.createBackup(virtualHost, ipAddress, backupLogPath, port)
|
backupSchedule.createBackup(virtualHost, ipAddress, backupLogPath, port)
|
||||||
|
|
||||||
|
|
||||||
|
backupSchedule.remoteBackupLogging(backupLogPath, "Remote backup job completed.\n")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
except BaseException,msg:
|
except BaseException,msg:
|
||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [prepare]")
|
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [prepare]")
|
||||||
|
|
||||||
|
|||||||
@@ -1,53 +1,10 @@
|
|||||||
import thread
|
|
||||||
import pexpect
|
|
||||||
import CyberCPLogFileWriter as logging
|
import CyberCPLogFileWriter as logging
|
||||||
import subprocess
|
|
||||||
import shlex
|
|
||||||
from shutil import rmtree
|
|
||||||
import os
|
import os
|
||||||
import requests
|
|
||||||
import json
|
|
||||||
import time
|
import time
|
||||||
|
from backupSchedule import backupSchedule
|
||||||
|
|
||||||
class backupScheduleLocal:
|
class backupScheduleLocal:
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def createBackup(virtualHost,writeToFile):
|
|
||||||
try:
|
|
||||||
|
|
||||||
writeToFile.writelines("[" + time.strftime(
|
|
||||||
"%I-%M-%S-%a-%b-%Y") + "]" + " Starting local backup for: "+virtualHost + "\n")
|
|
||||||
|
|
||||||
finalData = json.dumps({'websiteToBeBacked': virtualHost})
|
|
||||||
requests.post("http://localhost:5003/backup/submitBackupCreation", data=finalData)
|
|
||||||
|
|
||||||
writeToFile.writelines("[" + time.strftime(
|
|
||||||
"%I-%M-%S-%a-%b-%Y") + "]" + " Waiting for backup to complete.. " + "\n")
|
|
||||||
|
|
||||||
while (1):
|
|
||||||
r = requests.post("http://localhost:5003/backup/backupStatus", data= finalData)
|
|
||||||
time.sleep(2)
|
|
||||||
data = json.loads(r.text)
|
|
||||||
|
|
||||||
writeToFile.writelines("[" + time.strftime(
|
|
||||||
"%I-%M-%S-%a-%b-%Y") + "]" + " Waiting for backup to complete.. " + "\n")
|
|
||||||
|
|
||||||
if data['backupStatus'] == 0:
|
|
||||||
writeToFile.writelines("[" + time.strftime(
|
|
||||||
"%I-%M-%S-%a-%b-%Y") + "]" + "An error occurred, Error message: " + data['error_message'] + "\n")
|
|
||||||
break
|
|
||||||
elif data['abort'] == 1:
|
|
||||||
writeToFile.writelines("[" + time.strftime(
|
|
||||||
"%I-%M-%S-%a-%b-%Y") + "]" + " Backup Completed for: " + virtualHost + "\n")
|
|
||||||
|
|
||||||
writeToFile.writelines("[" + time.strftime(
|
|
||||||
"%I-%M-%S-%a-%b-%Y") + "]" + " #############################################" + "\n")
|
|
||||||
break
|
|
||||||
|
|
||||||
except BaseException,msg:
|
|
||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]")
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def prepare():
|
def prepare():
|
||||||
try:
|
try:
|
||||||
@@ -55,24 +12,25 @@ class backupScheduleLocal:
|
|||||||
|
|
||||||
writeToFile = open(backupLogPath, "a")
|
writeToFile = open(backupLogPath, "a")
|
||||||
|
|
||||||
writeToFile.writelines("#################################################\n")
|
backupSchedule.remoteBackupLogging(backupLogPath, "#################################################")
|
||||||
writeToFile.writelines(" Backup log for: " + time.strftime("%I-%M-%S-%a-%b-%Y") + "\n")
|
backupSchedule.remoteBackupLogging(backupLogPath," Local Backup log for: " + time.strftime("%I-%M-%S-%a-%b-%Y"))
|
||||||
writeToFile.writelines("#################################################\n")
|
backupSchedule.remoteBackupLogging(backupLogPath, "#################################################\n")
|
||||||
|
|
||||||
writeToFile.writelines("\n")
|
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||||
writeToFile.writelines("\n")
|
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||||
|
|
||||||
for virtualHost in os.listdir("/home"):
|
for virtualHost in os.listdir("/home"):
|
||||||
backupScheduleLocal.createBackup(virtualHost,writeToFile)
|
backupSchedule.createLocalBackup(virtualHost, backupLogPath)
|
||||||
|
|
||||||
writeToFile.writelines("\n")
|
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||||
writeToFile.writelines("\n")
|
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||||
writeToFile.writelines("[" + time.strftime(
|
|
||||||
"%I-%M-%S-%a-%b-%Y") + "]" + " #############################################" + "\n")
|
backupSchedule.remoteBackupLogging(backupLogPath, "#################################################")
|
||||||
writeToFile.writelines("[" + time.strftime(
|
|
||||||
"%I-%M-%S-%a-%b-%Y") + "]" + " Local Backup Completed" + "\n")
|
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||||
writeToFile.writelines("[" + time.strftime(
|
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||||
"%I-%M-%S-%a-%b-%Y") + "]" + " #############################################" + "\n")
|
|
||||||
|
backupSchedule.remoteBackupLogging(backupLogPath, "Local backup job completed.\n")
|
||||||
|
|
||||||
writeToFile.close()
|
writeToFile.close()
|
||||||
|
|
||||||
|
|||||||
@@ -533,7 +533,7 @@ app.controller('createACLCTRL', function($scope,$http) {
|
|||||||
var data = {
|
var data = {
|
||||||
|
|
||||||
aclName : $scope.aclName,
|
aclName : $scope.aclName,
|
||||||
makeAdmin : $scope.makeAdmin = true,
|
makeAdmin : $scope.makeAdmin,
|
||||||
|
|
||||||
//
|
//
|
||||||
versionManagement : $scope.versionManagement,
|
versionManagement : $scope.versionManagement,
|
||||||
|
|||||||
Reference in New Issue
Block a user