mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-14 17:26:17 +01:00
backup schedule bug fix
This commit is contained in:
@@ -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(
|
||||
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"
|
||||
backupOb.save()
|
||||
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
|
||||
|
||||
|
||||
@@ -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:
|
||||
if backupUtilities.checkIfHostIsUp(ipAddress) != 1:
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "Ping for : " + ipAddress + " does not seems to work, however we will continue.")
|
||||
|
||||
|
||||
checkConn = backupUtilities.checkConnection(ipAddress)
|
||||
if checkConn[0] == 0:
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "Connection to: " + ipAddress+ " Failed, please resetup this destination from CyberPanel, aborting.")
|
||||
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")
|
||||
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.")
|
||||
return 0
|
||||
|
||||
for virtualHost in os.listdir("/home"):
|
||||
if match(r'([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?', virtualHost, M | I):
|
||||
|
||||
Reference in New Issue
Block a user