Skip to content

Commit

Permalink
Apache URL
Browse files Browse the repository at this point in the history
  • Loading branch information
zarakkhan209 committed Feb 10, 2024
1 parent acfd8df commit 8b4c0ff
Show file tree
Hide file tree
Showing 21 changed files with 1,900 additions and 275 deletions.
47 changes: 37 additions & 10 deletions backup/backupManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from websiteFunctions.models import NormalBackupDests, NormalBackupJobs, NormalBackupSites
from plogical.IncScheduler import IncScheduler


class BackupManager:
localBackupPath = '/home/cyberpanel/localBackupPath'

Expand All @@ -56,14 +57,25 @@ def backupSite(self, request=None, userID=None, data=None):
proc = httpProc(request, 'backup/backup.html', {'websiteList': websitesName}, 'createBackup')
return proc.render()

def backupSiteV2(self, request=None, userID=None, data=None):
currentACL = ACLManager.loadedACL(userID)
websitesName = ACLManager.findAllSites(currentACL, userID)

command = 'chmod 755 /home/backup'
ProcessUtilities.executioner(command)

proc = httpProc(request, 'backup/backupV2.html', {'websiteList': websitesName}, 'createBackup')
return proc.render()

def RestoreV2backupSite(self, request=None, userID=None, data=None):
if ACLManager.CheckForPremFeature('all'):
BackupStat = 1
else:
BackupStat = 0
currentACL = ACLManager.loadedACL(userID)
websitesName = ACLManager.findAllSites(currentACL, userID)
proc = httpProc(request, 'IncBackups/RestoreV2Backup.html', {'websiteList': websitesName, 'BackupStat': BackupStat}, 'createBackup')
proc = httpProc(request, 'IncBackups/RestoreV2Backup.html',
{'websiteList': websitesName, 'BackupStat': BackupStat}, 'createBackup')
return proc.render()

def CreateV2backupSite(self, request=None, userID=None, data=None):
Expand All @@ -81,7 +93,8 @@ def schedulev2Backups(self, request=None, userID=None, data=None):

currentACL = ACLManager.loadedACL(userID)
websitesName = ACLManager.findAllSites(currentACL, userID)
proc = httpProc(request, 'IncBackups/ScheduleV2Backup.html', {'websiteList': websitesName, "BackupStat": BackupStat}, 'createBackup')
proc = httpProc(request, 'IncBackups/ScheduleV2Backup.html',
{'websiteList': websitesName, "BackupStat": BackupStat}, 'createBackup')
return proc.render()

def gDrive(self, request=None, userID=None, data=None):
Expand Down Expand Up @@ -340,7 +353,6 @@ def changeAccountFrequencygDrive(self, request=None, userID=None, data=None):
json_data = json.dumps(data_ret)
return HttpResponse(json_data)


def changeFileRetention(self, request=None, userID=None, data=None):
try:

Expand All @@ -362,15 +374,13 @@ def changeFileRetention(self, request=None, userID=None, data=None):
else:
return ACLManager.loadErrorJson('status', 0)



conf = gD.auth
# logging.CyberCPLogFileWriter.writeToFile("...... conf...%s " % conf)
config = json.loads(conf)
# logging.CyberCPLogFileWriter.writeToFile("...... config...%s " % config)
config['FileRetentiontime'] = Retentiontime

gD.auth=json.dumps(config)
gD.auth = json.dumps(config)
gD.save()

data_ret = {'status': 1}
Expand Down Expand Up @@ -435,6 +445,25 @@ def restoreSite(self, request=None, userID=None, data=None):
proc = httpProc(request, 'backup/restore.html', {'backups': all_files}, 'restoreBackup')
return proc.render()

def restoreSiteV2(self, request=None, userID=None, data=None):
path = os.path.join("/home", "backup")
if not os.path.exists(path):
proc = httpProc(request, 'backup/restoreV2.html', None, 'restoreBackup')
return proc.render()
else:
all_files = []
ext = ".tar.gz"

command = 'sudo chown -R cyberpanel:cyberpanel ' + path
ACLManager.executeCall(command)

files = os.listdir(path)
for filename in files:
if filename.endswith(ext):
all_files.append(filename)
proc = httpProc(request, 'backup/restoreV2.html', {'backups': all_files}, 'restoreBackup')
return proc.render()

def getCurrentBackups(self, userID=None, data=None):
try:
currentACL = ACLManager.loadedACL(userID)
Expand Down Expand Up @@ -1495,7 +1524,6 @@ def fetchgNormalSites(self, request=None, userID=None, data=None):
recordsToShow = int(data['recordsToShow'])
page = int(str(data['page']).strip('\n'))


if ACLManager.currentContextPermission(currentACL, 'scheduleBackups') == 0:
return ACLManager.loadErrorJson('scheduleStatus', 0)

Expand Down Expand Up @@ -1726,7 +1754,6 @@ def changeAccountFrequencyNormal(self, request=None, userID=None, data=None):
json_data = json.dumps(data_ret)
return HttpResponse(json_data)


def deleteAccountNormal(self, request=None, userID=None, data=None):
try:

Expand Down Expand Up @@ -1838,7 +1865,7 @@ def CreateV2BackupStatus(self, userID=None, data=None):
json_data = json.dumps(data_ret)
return HttpResponse(json_data)

#currentStatus:"cat: /home/cyberpanel/9219: No such file or directory"
# currentStatus:"cat: /home/cyberpanel/9219: No such file or directory"

statusData = ProcessUtilities.outputExecutioner("cat " + statusFile).splitlines()

Expand Down Expand Up @@ -1871,4 +1898,4 @@ def CreateV2BackupStatus(self, userID=None, data=None):
except BaseException as msg:
data_ret = {'abort': 0, 'installStatus': 0, 'installationProgress': "0", 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
return HttpResponse(json_data)
Loading

0 comments on commit 8b4c0ff

Please sign in to comment.