This commit is contained in:
Hassan Hashmi
2022-06-27 12:05:43 +05:00
parent 7a00a85093
commit 932faceef1
3 changed files with 79 additions and 1 deletions

View File

@@ -960,6 +960,78 @@ Automatic backup failed for %s on %s.
except BaseException as 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():
parser = argparse.ArgumentParser(description='CyberPanel Installer')
@@ -983,6 +1055,7 @@ def main():
###
IncScheduler.startBackup(args.function)
IncScheduler.RemoteBackup(args)
IncScheduler.runGoogleDriveBackups(args.function)
IncScheduler.git(args.function)
IncScheduler.checkDiskUsage()

View File

@@ -2272,6 +2272,8 @@ $parameters = array(
php = PHPManager.getPHPString(PhpVersion)
FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
### Website and Database Both === 1
if Backuptype == "1":
logging.statusWriter(self.tempStatusPath, 'Getting database...,20')
@@ -2435,6 +2437,7 @@ $parameters = array(
logging.statusWriter(self.tempStatusPath, 'Completed.[200]')
return 1, f"/home/backup/{config['name']}.tar.gz"
#### Only Website Data === 2
elif Backuptype == "2":
###Onlye website data
### Create secure folder
@@ -2563,6 +2566,8 @@ $parameters = array(
logging.statusWriter(self.tempStatusPath, 'Completed.[200]')
return 1, f"/home/backup/{config['name']}.tar.gz"
#### Only Database === 3
else:
###only backup of data base
logging.statusWriter(self.tempStatusPath, 'Getting database...,20')

View File

@@ -58,7 +58,7 @@
</div>
</div>
<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">
<select ng-model="BackupType"
class="form-control">