Usman Nasir
2021-12-25 14:03:11 +05:00
parent ade673dcbf
commit 2a0ebb2d04
2 changed files with 121 additions and 106 deletions

View File

@@ -20,15 +20,7 @@ from .models import IncJob, JobSnapshots
from websiteFunctions.models import Websites
import plogical.randomPassword as randomPassword
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
from xml.etree.ElementTree import Element, SubElement
from xml.etree import ElementTree
from xml.dom import minidom
from backup.models import DBUsers
import plogical.mysqlUtilities as mysqlUtilities
from plogical.backupUtilities import backupUtilities
from plogical.dnsUtilities import DNS
from mailServer.models import Domains as eDomains
from random import randint
import json
from django.shortcuts import HttpResponse
@@ -806,6 +798,8 @@ Subject: %s
def createBackup(self):
try:
self.statusPath = self.extraArgs['tempPath']
website = self.extraArgs['website']
self.backupDestinations = self.extraArgs['backupDestinations']
@@ -899,13 +893,18 @@ Subject: %s
try:
command = 'rm -f %s' % (metaPathNew)
#ProcessUtilities.executioner(command)
ProcessUtilities.executioner(command)
except BaseException as msg:
logging.statusWriter(self.statusPath,
'Failed to delete meta file: %s. [IncJobs.createBackup.591]' % str(msg), 1)
logging.statusWriter(self.statusPath, 'Completed', 1)
except BaseException as msg:
logging.statusWriter(self.statusPath,
'Failed to create incremental backup: %s. [5009][IncJobs.createBackup.913]' % str(msg), 1)
### Delete Snapshot
def DeleteSnapShot(self, inc_job):

View File

@@ -31,9 +31,9 @@ try:
from plogical.processUtilities import ProcessUtilities
except:
pass
import threading as multi
class IncScheduler():
class IncScheduler(multi.Thread):
logPath = '/home/cyberpanel/incbackuplogs'
gitFolder = '/home/cyberpanel/git'
@@ -46,6 +46,15 @@ class IncScheduler():
currentStatus = 'currentStatus'
lastRun = 'lastRun'
def __init__(self, function, extraArgs):
multi.Thread.__init__(self)
self.function = function
self.data = extraArgs
def run(self):
if self.function == 'startBackup':
IncScheduler.startBackup(self.data['freq'])
@staticmethod
def startBackup(type):
try:
@@ -828,7 +837,6 @@ Automatic backup failed for %s on %s.
except BaseException as msg:
logging.writeToFile('%s. [WPUpdates:767]' % (str(msg)))
def main():
parser = argparse.ArgumentParser(description='CyberPanel Installer')
@@ -842,6 +850,14 @@ def main():
IncScheduler.CalculateAndUpdateDiskUsage()
IncScheduler.WPUpdates()
### Run incremental backups in sep thread
ib = IncScheduler('startBackup', {'freq': args.function})
ib.start()
###
IncScheduler.startBackup(args.function)
IncScheduler.runGoogleDriveBackups(args.function)
IncScheduler.git(args.function)