mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-08 22:36:12 +01:00
cron
This commit is contained in:
@@ -960,6 +960,78 @@ Automatic backup failed for %s on %s.
|
|||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
logging.writeToFile('%s. [WPUpdates:767]' % (str(msg)))
|
logging.writeToFile('%s. [WPUpdates:767]' % (str(msg)))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def RemoteBackup():
|
||||||
|
from websiteFunctions.models import RemoteBackupSchedule, RemoteBackupsites, WPSites
|
||||||
|
from loginSystem.models import Administrator
|
||||||
|
import json
|
||||||
|
for config in RemoteBackupSchedule.objects.all():
|
||||||
|
try:
|
||||||
|
RemoteBackupsiteobj = RemoteBackupsites.objects.filter(owner=config.pk)
|
||||||
|
backupsiteID=RemoteBackupsiteobj.WPsites
|
||||||
|
wpsite=WPSites.objects.get(pk=backupsiteID)
|
||||||
|
AdminID=wpsite.owner.admin_id
|
||||||
|
Admin = Administrator.objects.get(pk=AdminID)
|
||||||
|
|
||||||
|
except:
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
configbakup=json.loads(config.config)
|
||||||
|
backuptype = configbakup['BackupType']
|
||||||
|
if backuptype == 'Only DataBase':
|
||||||
|
Backuptype = "3"
|
||||||
|
elif backuptype == 'Only Website'
|
||||||
|
Backuptype = "2"
|
||||||
|
else:
|
||||||
|
Backuptype = "1"
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
extraArgs = {}
|
||||||
|
extraArgs['adminID'] = Admin.pk
|
||||||
|
extraArgs['WPid'] = wpsite.pk
|
||||||
|
extraArgs['Backuptype'] = Backuptype
|
||||||
|
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||||
|
|
||||||
|
Lastrun = config.lastrun
|
||||||
|
Currenttime = float(time.time())
|
||||||
|
if config.timeintervel == "30 Minutes":
|
||||||
|
al = float(Currenttime) - float(1800)
|
||||||
|
if float(al) >= float(Lastrun):
|
||||||
|
background = ApplicationInstaller('WPCreateBackup', extraArgs)
|
||||||
|
background.start()
|
||||||
|
elif config.timeintervel =="1 Hour":
|
||||||
|
al = float(Currenttime) - float(3600)
|
||||||
|
if float(al) >= float(Lastrun):
|
||||||
|
background = ApplicationInstaller('WPCreateBackup', extraArgs)
|
||||||
|
background.start()
|
||||||
|
elif config.timeintervel =="6 Hours":
|
||||||
|
al = float(Currenttime) - float(21600)
|
||||||
|
if float(al) >= float(Lastrun):
|
||||||
|
background = ApplicationInstaller('WPCreateBackup', extraArgs)
|
||||||
|
background.start()
|
||||||
|
elif config.timeintervel =="12 Hours":
|
||||||
|
al = float(Currenttime) - float(43200)
|
||||||
|
if float(al) >= float(Lastrun):
|
||||||
|
background = ApplicationInstaller('WPCreateBackup', extraArgs)
|
||||||
|
background.start()
|
||||||
|
elif config.timeintervel =="1 Day":
|
||||||
|
al = float(Currenttime) - float(86400)
|
||||||
|
if float(al) >= float(Lastrun):
|
||||||
|
background = ApplicationInstaller('WPCreateBackup', extraArgs)
|
||||||
|
background.start()
|
||||||
|
elif config.timeintervel =="3 Days":
|
||||||
|
al = float(Currenttime) - float(259200)
|
||||||
|
if float(al) >= float(Lastrun):
|
||||||
|
background = ApplicationInstaller('WPCreateBackup', extraArgs)
|
||||||
|
background.start()
|
||||||
|
elif config.timeintervel =="1 Week":
|
||||||
|
al = float(Currenttime) - float(604800)
|
||||||
|
if float(al) >= float(Lastrun):
|
||||||
|
background = ApplicationInstaller('WPCreateBackup', extraArgs)
|
||||||
|
background.start()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description='CyberPanel Installer')
|
parser = argparse.ArgumentParser(description='CyberPanel Installer')
|
||||||
@@ -983,6 +1055,7 @@ def main():
|
|||||||
###
|
###
|
||||||
|
|
||||||
IncScheduler.startBackup(args.function)
|
IncScheduler.startBackup(args.function)
|
||||||
|
IncScheduler.RemoteBackup(args)
|
||||||
IncScheduler.runGoogleDriveBackups(args.function)
|
IncScheduler.runGoogleDriveBackups(args.function)
|
||||||
IncScheduler.git(args.function)
|
IncScheduler.git(args.function)
|
||||||
IncScheduler.checkDiskUsage()
|
IncScheduler.checkDiskUsage()
|
||||||
|
|||||||
@@ -2272,6 +2272,8 @@ $parameters = array(
|
|||||||
php = PHPManager.getPHPString(PhpVersion)
|
php = PHPManager.getPHPString(PhpVersion)
|
||||||
FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
|
FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
|
||||||
|
|
||||||
|
|
||||||
|
### Website and Database Both === 1
|
||||||
if Backuptype == "1":
|
if Backuptype == "1":
|
||||||
|
|
||||||
logging.statusWriter(self.tempStatusPath, 'Getting database...,20')
|
logging.statusWriter(self.tempStatusPath, 'Getting database...,20')
|
||||||
@@ -2435,6 +2437,7 @@ $parameters = array(
|
|||||||
logging.statusWriter(self.tempStatusPath, 'Completed.[200]')
|
logging.statusWriter(self.tempStatusPath, 'Completed.[200]')
|
||||||
return 1, f"/home/backup/{config['name']}.tar.gz"
|
return 1, f"/home/backup/{config['name']}.tar.gz"
|
||||||
|
|
||||||
|
#### Only Website Data === 2
|
||||||
elif Backuptype == "2":
|
elif Backuptype == "2":
|
||||||
###Onlye website data
|
###Onlye website data
|
||||||
### Create secure folder
|
### Create secure folder
|
||||||
@@ -2563,6 +2566,8 @@ $parameters = array(
|
|||||||
|
|
||||||
logging.statusWriter(self.tempStatusPath, 'Completed.[200]')
|
logging.statusWriter(self.tempStatusPath, 'Completed.[200]')
|
||||||
return 1, f"/home/backup/{config['name']}.tar.gz"
|
return 1, f"/home/backup/{config['name']}.tar.gz"
|
||||||
|
|
||||||
|
#### Only Database === 3
|
||||||
else:
|
else:
|
||||||
###only backup of data base
|
###only backup of data base
|
||||||
logging.statusWriter(self.tempStatusPath, 'Getting database...,20')
|
logging.statusWriter(self.tempStatusPath, 'Getting database...,20')
|
||||||
|
|||||||
@@ -58,7 +58,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div ng-hide="installationDetailsForm" class="form-group">
|
<div ng-hide="installationDetailsForm" class="form-group">
|
||||||
<label class="col-sm-3 control-label">{% trans "Back Type" %}</label>
|
<label class="col-sm-3 control-label">{% trans "Backup Type" %}</label>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<select ng-model="BackupType"
|
<select ng-model="BackupType"
|
||||||
class="form-control">
|
class="form-control">
|
||||||
|
|||||||
Reference in New Issue
Block a user