mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-13 16:56:09 +01:00
added schedule backend to v2backups
This commit is contained in:
@@ -10,11 +10,17 @@
|
|||||||
{% if PremStat %}
|
{% if PremStat %}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div id="page-title">
|
<div id="page-title">
|
||||||
<h2>{% trans "SSL v2" %} - <a target="_blank" href="http://go.cyberpanel.net/dns-records"
|
<h2>{% trans "SSL v2" %} - <a target="_blank" href="https://youtu.be/kDUANNvtOwE"
|
||||||
style="height: 23px;line-height: 21px;"
|
style="height: 23px;line-height: 21px;"
|
||||||
class="btn btn-border btn-alt border-red btn-link font-red"
|
class="btn btn-border btn-alt border-red btn-link font-red"
|
||||||
title=""><span>{% trans "DNS Docs" %}</span></a></h2>
|
title=""><span>{% trans "DNS Docs" %}</span></a></h2>
|
||||||
<p>{% trans "On this page, you have the option to configure DNS providers that CyberPanel can utilize for issuing SSL certificates, providing enhanced flexibility and ease of renewal." %}</p>
|
<p>{% trans "On this page, you have the option to configure DNS providers that CyberPanel can utilize for issuing SSL certificates, providing enhanced flexibility and ease of renewal." %}</p>
|
||||||
|
<p align="center" style="margin-top: 2%; margin-bottom: 2%">
|
||||||
|
<iframe width="788.54" height="443" src="https://youtu.be/kDUANNvtOwE"
|
||||||
|
title="YouTube video player" frameborder="0"
|
||||||
|
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
||||||
|
allowfullscreen></iframe>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div ng-controller="sslIssueCtrlV2" class="panel">
|
<div ng-controller="sslIssueCtrlV2" class="panel">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
@@ -166,7 +172,7 @@
|
|||||||
protected. Don't wait any longer to upgrade your website's security - get SSL v2 today!<br></p>
|
protected. Don't wait any longer to upgrade your website's security - get SSL v2 today!<br></p>
|
||||||
</div>
|
</div>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<iframe width="788.54" height="443" src="https://www.youtube.com/embed/c-ffIKgjrBU"
|
<iframe width="788.54" height="443" src="https://youtu.be/kDUANNvtOwE"
|
||||||
title="YouTube video player" frameborder="0"
|
title="YouTube video player" frameborder="0"
|
||||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
||||||
allowfullscreen></iframe>
|
allowfullscreen></iframe>
|
||||||
|
|||||||
@@ -420,6 +420,7 @@ token = {token}
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
self.UpdateStatus('Backup config created,5', CPBackupsV2.RUNNING)
|
self.UpdateStatus('Backup config created,5', CPBackupsV2.RUNNING)
|
||||||
|
|
||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
self.UpdateStatus(f'Failed during config generation, Error: {str(msg)}', CPBackupsV2.FAILED)
|
self.UpdateStatus(f'Failed during config generation, Error: {str(msg)}', CPBackupsV2.FAILED)
|
||||||
return 0
|
return 0
|
||||||
@@ -453,6 +454,7 @@ token = {token}
|
|||||||
self.MergeSnapshots()
|
self.MergeSnapshots()
|
||||||
|
|
||||||
self.UpdateStatus('Completed', CPBackupsV2.COMPLETED)
|
self.UpdateStatus('Completed', CPBackupsV2.COMPLETED)
|
||||||
|
return 1
|
||||||
|
|
||||||
break
|
break
|
||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
@@ -725,6 +727,19 @@ token = {token}
|
|||||||
self.website.BackupLock = 0
|
self.website.BackupLock = 0
|
||||||
self.website.save()
|
self.website.save()
|
||||||
|
|
||||||
|
### Delete Snapshots
|
||||||
|
|
||||||
|
def DeleteSnapshots(self, deleteString):
|
||||||
|
|
||||||
|
### if restore then status file should be restore status file
|
||||||
|
|
||||||
|
from websiteFunctions.models import Websites
|
||||||
|
self.website = Websites.objects.get(domain=self.data['domain'])
|
||||||
|
|
||||||
|
|
||||||
|
command = f'rustic -r {self.repo} forget {deleteString} --prune --password "" 2>/dev/null'
|
||||||
|
result = ProcessUtilities.outputExecutioner(command, None, True)
|
||||||
|
|
||||||
# def BackupEmails(self):
|
# def BackupEmails(self):
|
||||||
#
|
#
|
||||||
# ### This function will backup emails of the website, also need to take care of emails that we need to exclude
|
# ### This function will backup emails of the website, also need to take care of emails that we need to exclude
|
||||||
|
|||||||
@@ -1393,6 +1393,77 @@ Automatic backup failed for %s on %s.
|
|||||||
for website in Websites.objects.all():
|
for website in Websites.objects.all():
|
||||||
virtualHostUtilities.setupAutoDiscover(1, '/home/cyberpanel/templogs', website.domain, website.admin)
|
virtualHostUtilities.setupAutoDiscover(1, '/home/cyberpanel/templogs', website.domain, website.admin)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def v2Backups(function):
|
||||||
|
try:
|
||||||
|
# print("....start remote backup...............")
|
||||||
|
from websiteFunctions.models import Websites
|
||||||
|
from loginSystem.models import Administrator
|
||||||
|
import json
|
||||||
|
import time
|
||||||
|
if os.path.exists('/home/cyberpanel/v2backups'):
|
||||||
|
for website in Websites.objects.all():
|
||||||
|
finalConfigPath = f'/home/cyberpanel/v2backups/{website.domain}'
|
||||||
|
if os.path.exists(finalConfigPath):
|
||||||
|
|
||||||
|
command = f'cat {finalConfigPath}'
|
||||||
|
RetResult = ProcessUtilities.outputExecutioner(command)
|
||||||
|
print(repr(RetResult))
|
||||||
|
BackupConfig = json.loads(ProcessUtilities.outputExecutioner(command).rstrip('\n'))
|
||||||
|
|
||||||
|
for key, value in BackupConfig.items():
|
||||||
|
try:
|
||||||
|
print(key, '->', value)
|
||||||
|
if key == 'site':
|
||||||
|
continue
|
||||||
|
if value['frequency'] == function:
|
||||||
|
extra_args = {}
|
||||||
|
extra_args['function'] = 'InitiateBackup'
|
||||||
|
extra_args['website'] = website.domain
|
||||||
|
extra_args['domain'] = website.domain
|
||||||
|
extra_args['BasePath'] = '/home/backup'
|
||||||
|
extra_args['BackendName'] = key
|
||||||
|
extra_args['BackupData'] = value['websiteData'] if 'websiteData' in value else False
|
||||||
|
extra_args['BackupEmails'] = value['websiteEmails'] if 'websiteEmails' in value else False
|
||||||
|
extra_args['BackupDatabase'] = value['websiteDatabases'] if 'websiteDatabases' in value else False
|
||||||
|
|
||||||
|
from plogical.Backupsv2 import CPBackupsV2
|
||||||
|
background = CPBackupsV2(extra_args)
|
||||||
|
RetStatus = background.InitiateBackup()
|
||||||
|
|
||||||
|
print(RetStatus)
|
||||||
|
|
||||||
|
if RetStatus == 0:
|
||||||
|
SUBJECT = "Automatic Backupv2 failed for %s on %s." % (website.domain, time.strftime("%m.%d.%Y_%H-%M-%S"))
|
||||||
|
adminEmailPath = '/home/cyberpanel/adminEmail'
|
||||||
|
adminEmail = open(adminEmailPath, 'r').read().rstrip('\n')
|
||||||
|
sender = 'root@%s' % (socket.gethostname())
|
||||||
|
error = ProcessUtilities.outputExecutioner(f'cat {background.StatusFile}')
|
||||||
|
TO = [adminEmail]
|
||||||
|
message = f"""\
|
||||||
|
From: %s
|
||||||
|
To: %s
|
||||||
|
Subject: %s
|
||||||
|
Automatic Backupv2 failed for %s on %s.
|
||||||
|
{error}
|
||||||
|
""" % (sender, ", ".join(TO), SUBJECT, website.domain, time.strftime("%m.%d.%Y_%H-%M-%S"))
|
||||||
|
|
||||||
|
logging.SendEmail(sender, TO, message)
|
||||||
|
else:
|
||||||
|
BackupConfig[key]['lastRun'] = time.strftime("%m.%d.%Y_%H-%M-%S")
|
||||||
|
except BaseException as msg:
|
||||||
|
print("Error: [v2Backups]: %s" % str(msg))
|
||||||
|
logging.writeToFile('%s. [v2Backups]' % (str(msg)))
|
||||||
|
|
||||||
|
FinalContent = json.dumps(BackupConfig)
|
||||||
|
WriteToFile = open(finalConfigPath, 'w')
|
||||||
|
WriteToFile.write(FinalContent)
|
||||||
|
WriteToFile.close()
|
||||||
|
|
||||||
|
except BaseException as msg:
|
||||||
|
print("Error: [v2Backups]: %s" % str(msg))
|
||||||
|
logging.writeToFile('%s. [v2Backups]' % (str(msg)))
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description='CyberPanel Installer')
|
parser = argparse.ArgumentParser(description='CyberPanel Installer')
|
||||||
@@ -1404,8 +1475,9 @@ def main():
|
|||||||
IncScheduler.CalculateAndUpdateDiskUsage()
|
IncScheduler.CalculateAndUpdateDiskUsage()
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if args.function == '30 Minutes' or args.function == '30 Minutes'or args.function == 'Daily' or args.function == '1 Hour' or args.function == '6 Hours' or args.function == '12 Hours' or args.function == '1 Day' or args.function == '3 Days' or args.function == '1 Week':
|
if args.function == '30 Minutes' or args.function == 'Daily' or args.function == '1 Hour' or args.function == '6 Hours' or args.function == '12 Hours' or args.function == '1 Day' or args.function == '3 Days' or args.function == '1 Week':
|
||||||
IncScheduler.RemoteBackup(args.function)
|
IncScheduler.RemoteBackup(args.function)
|
||||||
|
IncScheduler.v2Backups(args.function)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if args.function == 'forceRunAWSBackup':
|
if args.function == 'forceRunAWSBackup':
|
||||||
|
|||||||
@@ -294,6 +294,10 @@ class ProcessUtilities(multi.Thread):
|
|||||||
if getpass.getuser() == 'root':
|
if getpass.getuser() == 'root':
|
||||||
if os.path.exists(ProcessUtilities.debugPath):
|
if os.path.exists(ProcessUtilities.debugPath):
|
||||||
logging.writeToFile(command)
|
logging.writeToFile(command)
|
||||||
|
|
||||||
|
if user!=None:
|
||||||
|
if not command.startswith('sudo'):
|
||||||
|
command = f'sudo -u {user} {command}'
|
||||||
if shell == None or shell == True:
|
if shell == None or shell == True:
|
||||||
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user