This commit is contained in:
Usman Nasir
2022-04-24 22:01:54 +05:00
parent 664936f51a
commit 940e4de0f6
4 changed files with 12 additions and 14 deletions

View File

@@ -114,7 +114,7 @@
<div ng-hide="driveHidden" id="checkret" class="form-group"> <div ng-hide="driveHidden" id="checkret" class="form-group">
<label class="col-sm-3 control-label">{% trans "Backup File Retention" %}</label> <label class="col-sm-3 control-label">{% trans "Backup File Retention" %} (<a href="https://cyberpanel.net/cyberpanel-addons">Paid Feature</a> )</label>
<div class="col-sm-6"> <div class="col-sm-6">
<select id="fileretention" ng-model="Retentiontime" ng-change="changeRetention()" class="form-control"> <select id="fileretention" ng-model="Retentiontime" ng-change="changeRetention()" class="form-control">
<option value="1d">1 days</option> <option value="1d">1 days</option>

View File

@@ -224,7 +224,8 @@ def FileManagerRoot(request):
if(Status == 1): if(Status == 1):
template = 'baseTemplate/FileManager.html' template = 'baseTemplate/FileManager.html'
else: else:
return redirect("https://cyberpanel.net/adons") return redirect("https://cyberpanel.net/cyberpanel-addons")
except BaseException as msg: except BaseException as msg:
template = 'baseTemplate/FileManager.html' template = 'baseTemplate/FileManager.html'

View File

@@ -1,11 +1,9 @@
#!/usr/local/CyberCP/bin/python #!/usr/local/CyberCP/bin/python
import os.path import os.path
import sys import sys
sys.path.append('/usr/local/CyberCP') sys.path.append('/usr/local/CyberCP')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
import django import django
django.setup() django.setup()
from IncBackups.IncBackupsControl import IncJobs from IncBackups.IncBackupsControl import IncJobs
from IncBackups.models import BackupJob from IncBackups.models import BackupJob
@@ -24,7 +22,6 @@ import requests
import socket import socket
from websiteFunctions.models import NormalBackupJobs, NormalBackupJobLogs from websiteFunctions.models import NormalBackupJobs, NormalBackupJobLogs
from boto3.s3.transfer import TransferConfig from boto3.s3.transfer import TransferConfig
try: try:
from s3Backups.models import BackupPlan, BackupLogs from s3Backups.models import BackupPlan, BackupLogs
import boto3 import boto3
@@ -235,6 +232,11 @@ class IncScheduler(multi.Thread):
@staticmethod @staticmethod
def runGoogleDriveBackups(type): def runGoogleDriveBackups(type):
ipFile = "/etc/cyberpanel/machineIP"
f = open(ipFile)
ipData = f.read()
ipAddress = ipData.split('\n', 1)[0]
backupRunTime = time.strftime("%m.%d.%Y_%H-%M-%S") backupRunTime = time.strftime("%m.%d.%Y_%H-%M-%S")
backupLogPath = "/usr/local/lscp/logs/local_backup_log." + backupRunTime backupLogPath = "/usr/local/lscp/logs/local_backup_log." + backupRunTime
@@ -256,6 +258,7 @@ class IncScheduler(multi.Thread):
finalData = json.dumps({'refresh_token': gDriveData['refresh_token']}) finalData = json.dumps({'refresh_token': gDriveData['refresh_token']})
r = requests.post("https://platform.cyberpersons.com/refreshToken", data=finalData r = requests.post("https://platform.cyberpersons.com/refreshToken", data=finalData
) )
gDriveData['token'] = json.loads(r.text)['access_token'] gDriveData['token'] = json.loads(r.text)['access_token']
credentials = google.oauth2.credentials.Credentials(gDriveData['token'], credentials = google.oauth2.credentials.Credentials(gDriveData['token'],
@@ -280,11 +283,6 @@ class IncScheduler(multi.Thread):
folderIDIP = gDriveData['folderIDIP'] folderIDIP = gDriveData['folderIDIP']
except: except:
ipFile = "/etc/cyberpanel/machineIP"
f = open(ipFile)
ipData = f.read()
ipAddress = ipData.split('\n', 1)[0]
## Create CyberPanel Folder ## Create CyberPanel Folder
file_metadata = { file_metadata = {
@@ -349,6 +347,7 @@ class IncScheduler(multi.Thread):
try: try:
drive.files().create(body=file_metadata, media_body=media, fields='id').execute() drive.files().create(body=file_metadata, media_body=media, fields='id').execute()
except: except:
import requests
finalData = json.dumps({'refresh_token': gDriveData['refresh_token']}) finalData = json.dumps({'refresh_token': gDriveData['refresh_token']})
r = requests.post("https://platform.cyberpersons.com/refreshToken", data=finalData r = requests.post("https://platform.cyberpersons.com/refreshToken", data=finalData
) )
@@ -381,7 +380,7 @@ class IncScheduler(multi.Thread):
print("job com[leted") print("job com[leted")
logging.writeToFile('job completed') #logging.writeToFile('job completed')
url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission" url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission"
data = { data = {
@@ -461,8 +460,6 @@ class IncScheduler(multi.Thread):
except BaseException as msg: except BaseException as msg:
logging.writeToFile('job not completed [ERROR:]..%s'%msg) logging.writeToFile('job not completed [ERROR:]..%s'%msg)
except BaseException as msg: except BaseException as msg:
GDriveJobLogs(owner=items, status=backupSchedule.ERROR, GDriveJobLogs(owner=items, status=backupSchedule.ERROR,
message='[Completely] Job failed, Error message: %s.' % (str(msg))).save() message='[Completely] Job failed, Error message: %s.' % (str(msg))).save()

View File

@@ -1 +1 @@
{"version":"2.1","build":1} {"version":"2.3","build":1}