mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-06 05:15:49 +01:00
Updated to add BackupRetention to IncBackup and Backup models and script for future use
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
|
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from websiteFunctions.models import Websites
|
from websiteFunctions.models import Websites
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
class IncJob(models.Model):
|
class IncJob(models.Model):
|
||||||
website = models.ForeignKey(Websites, on_delete=models.CASCADE)
|
website = models.ForeignKey(Websites, on_delete=models.CASCADE)
|
||||||
date = models.DateTimeField(default=datetime.now, blank=True)
|
date = models.DateTimeField(default=datetime.now, blank=True)
|
||||||
|
|
||||||
|
|
||||||
class JobSnapshots(models.Model):
|
class JobSnapshots(models.Model):
|
||||||
job = models.ForeignKey(IncJob, on_delete=models.CASCADE)
|
job = models.ForeignKey(IncJob, on_delete=models.CASCADE)
|
||||||
type = models.CharField(max_length=300)
|
type = models.CharField(max_length=300)
|
||||||
@@ -21,10 +21,9 @@ class BackupJob(models.Model):
|
|||||||
websiteData = models.IntegerField()
|
websiteData = models.IntegerField()
|
||||||
websiteDatabases = models.IntegerField()
|
websiteDatabases = models.IntegerField()
|
||||||
websiteDataEmails = models.IntegerField()
|
websiteDataEmails = models.IntegerField()
|
||||||
|
retention = models.IntegerField()
|
||||||
|
|
||||||
|
|
||||||
class JobSites(models.Model):
|
class JobSites(models.Model):
|
||||||
job = models.ForeignKey(BackupJob, on_delete=models.CASCADE)
|
job = models.ForeignKey(BackupJob, on_delete=models.CASCADE)
|
||||||
website = models.CharField(max_length=300)
|
website = models.CharField(max_length=300)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -599,6 +599,7 @@ app.controller('scheduleBackupInc', function ($scope, $http) {
|
|||||||
var data = {
|
var data = {
|
||||||
backupDestinations: $scope.backupDest,
|
backupDestinations: $scope.backupDest,
|
||||||
backupFreq: $scope.backupFreq,
|
backupFreq: $scope.backupFreq,
|
||||||
|
backupRetention: $scope.backupRetention,
|
||||||
websiteData: $scope.websiteData,
|
websiteData: $scope.websiteData,
|
||||||
websiteEmails: $scope.websiteEmails,
|
websiteEmails: $scope.websiteEmails,
|
||||||
websiteDatabases: $scope.websiteDatabases,
|
websiteDatabases: $scope.websiteDatabases,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div id="page-title">
|
<div id="page-title">
|
||||||
<h2>{% trans "Schedule Back up" %} - <a target="_blank" href="http://cyberpanel.net/"
|
<h2>{% trans "Schedule Back up" %} - <a target="_blank" href="https://cyberpanel.net/"
|
||||||
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 "Remote Backups" %}</span></a></h2>
|
title=""><span>{% trans "Remote Backups" %}</span></a></h2>
|
||||||
@@ -50,6 +50,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div ng-hide="scheduleRetention" class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">{% trans "Select Backup Retention. Leave 0 for no limit" %}</label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<div class="number">
|
||||||
|
<label>
|
||||||
|
<input ng-model="backupRetention" type="number" value="0">
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div ng-hide="scheduleFreq" class="form-group">
|
<div ng-hide="scheduleFreq" class="form-group">
|
||||||
<label class="col-sm-3 control-label">{% trans "Backup Content" %}</label>
|
<label class="col-sm-3 control-label">{% trans "Backup Content" %}</label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
|
|||||||
@@ -524,6 +524,7 @@ def submit_backup_schedule(request):
|
|||||||
|
|
||||||
backup_dest = data['backupDestinations']
|
backup_dest = data['backupDestinations']
|
||||||
backup_freq = data['backupFreq']
|
backup_freq = data['backupFreq']
|
||||||
|
backup_retention = data['backupRetention']
|
||||||
backup_sites = data['websitesToBeBacked']
|
backup_sites = data['websitesToBeBacked']
|
||||||
|
|
||||||
backup_data = 1 if 'websiteData' in data else 0
|
backup_data = 1 if 'websiteData' in data else 0
|
||||||
@@ -531,7 +532,8 @@ def submit_backup_schedule(request):
|
|||||||
backup_databases = 1 if 'websiteDatabases' in data else 0
|
backup_databases = 1 if 'websiteDatabases' in data else 0
|
||||||
|
|
||||||
backup_job = BackupJob(websiteData=backup_data, websiteDataEmails=backup_emails,
|
backup_job = BackupJob(websiteData=backup_data, websiteDataEmails=backup_emails,
|
||||||
websiteDatabases=backup_databases, destination=backup_dest, frequency=backup_freq)
|
websiteDatabases=backup_databases, destination=backup_dest, frequency=backup_freq,
|
||||||
|
retention=backup_retention)
|
||||||
backup_job.save()
|
backup_job.save()
|
||||||
|
|
||||||
for site in backup_sites:
|
for site in backup_sites:
|
||||||
@@ -558,6 +560,7 @@ def get_current_backup_schedules(request):
|
|||||||
json_data.append({'id': items.id,
|
json_data.append({'id': items.id,
|
||||||
'destination': items.destination,
|
'destination': items.destination,
|
||||||
'frequency': items.frequency,
|
'frequency': items.frequency,
|
||||||
|
'retention': items.retention,
|
||||||
'numberOfSites': items.jobsites_set.all().count()
|
'numberOfSites': items.jobsites_set.all().count()
|
||||||
})
|
})
|
||||||
final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data})
|
final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data})
|
||||||
|
|||||||
@@ -886,6 +886,7 @@ class BackupManager:
|
|||||||
selectedAccount = data['selectedAccount']
|
selectedAccount = data['selectedAccount']
|
||||||
name = data['name']
|
name = data['name']
|
||||||
backupFrequency = data['backupFrequency']
|
backupFrequency = data['backupFrequency']
|
||||||
|
backupRetention = data['backupRetention']
|
||||||
|
|
||||||
currentACL = ACLManager.loadedACL(userID)
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
|
|
||||||
@@ -894,7 +895,8 @@ class BackupManager:
|
|||||||
|
|
||||||
nbd = NormalBackupDests.objects.get(name=selectedAccount)
|
nbd = NormalBackupDests.objects.get(name=selectedAccount)
|
||||||
|
|
||||||
config = {'frequency': backupFrequency}
|
config = {'frequency': backupFrequency,
|
||||||
|
'retention': backupRetention}
|
||||||
|
|
||||||
nbj = NormalBackupJobs(owner=nbd, name=name, config=json.dumps(config))
|
nbj = NormalBackupJobs(owner=nbd, name=name, config=json.dumps(config))
|
||||||
nbj.save()
|
nbj.save()
|
||||||
@@ -1465,6 +1467,11 @@ class BackupManager:
|
|||||||
except:
|
except:
|
||||||
frequency = 'Never'
|
frequency = 'Never'
|
||||||
|
|
||||||
|
try:
|
||||||
|
retention = config[IncScheduler.retention]
|
||||||
|
except:
|
||||||
|
retention = 'Never'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
currentStatus = config[IncScheduler.currentStatus]
|
currentStatus = config[IncScheduler.currentStatus]
|
||||||
except:
|
except:
|
||||||
@@ -1615,6 +1622,7 @@ class BackupManager:
|
|||||||
|
|
||||||
selectedJob = data['selectedJob']
|
selectedJob = data['selectedJob']
|
||||||
backupFrequency = data['backupFrequency']
|
backupFrequency = data['backupFrequency']
|
||||||
|
backupRetention = data['backupRetention']
|
||||||
|
|
||||||
nbj = NormalBackupJobs.objects.get(name=selectedJob)
|
nbj = NormalBackupJobs.objects.get(name=selectedJob)
|
||||||
|
|
||||||
@@ -1623,6 +1631,7 @@ class BackupManager:
|
|||||||
|
|
||||||
config = json.loads(nbj.config)
|
config = json.loads(nbj.config)
|
||||||
config[IncScheduler.frequency] = backupFrequency
|
config[IncScheduler.frequency] = backupFrequency
|
||||||
|
config[IncScheduler.retention] = backupRetention
|
||||||
|
|
||||||
nbj.config = json.dumps(config)
|
nbj.config = json.dumps(config)
|
||||||
nbj.save()
|
nbj.save()
|
||||||
|
|||||||
@@ -1247,7 +1247,8 @@ app.controller('googleDrive', function ($scope, $http) {
|
|||||||
};
|
};
|
||||||
var data = {
|
var data = {
|
||||||
selectedAccount: $scope.selectedAccount,
|
selectedAccount: $scope.selectedAccount,
|
||||||
backupFrequency: $scope.backupFrequency
|
backupFrequency: $scope.backupFrequency,
|
||||||
|
backupRetention: $scope.backupRetention,
|
||||||
};
|
};
|
||||||
|
|
||||||
dataurl = "/backup/changeAccountFrequencygDrive";
|
dataurl = "/backup/changeAccountFrequencygDrive";
|
||||||
@@ -1654,7 +1655,8 @@ app.controller('scheduleBackup', function ($scope, $http, $window) {
|
|||||||
var data = {
|
var data = {
|
||||||
selectedAccount: $scope.selectedAccountAdd,
|
selectedAccount: $scope.selectedAccountAdd,
|
||||||
name: $scope.name,
|
name: $scope.name,
|
||||||
backupFrequency: $scope.backupFrequency
|
backupFrequency: $scope.backupFrequency,
|
||||||
|
backupRetention: $scope.backupRetention,
|
||||||
};
|
};
|
||||||
|
|
||||||
dataurl = "/backup/submitBackupSchedule";
|
dataurl = "/backup/submitBackupSchedule";
|
||||||
@@ -1856,7 +1858,8 @@ app.controller('scheduleBackup', function ($scope, $http, $window) {
|
|||||||
};
|
};
|
||||||
var data = {
|
var data = {
|
||||||
selectedJob: $scope.selectedJob,
|
selectedJob: $scope.selectedJob,
|
||||||
backupFrequency: $scope.backupFrequency
|
backupFrequency: $scope.backupFrequency,
|
||||||
|
backupRetention: $scope.backupRetention,
|
||||||
};
|
};
|
||||||
|
|
||||||
dataurl = "/backup/changeAccountFrequencyNormal";
|
dataurl = "/backup/changeAccountFrequencyNormal";
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<div ng-controller="scheduleBackup" class="container">
|
<div ng-controller="scheduleBackup" class="container">
|
||||||
<div id="page-title">
|
<div id="page-title">
|
||||||
<h2>{% trans "Schedule Back up" %} - <a target="_blank"
|
<h2>{% trans "Schedule Back up" %} - <a target="_blank"
|
||||||
href="http://go.cyberpanel.net/remote-backup"
|
href="https://go.cyberpanel.net/remote-backup"
|
||||||
style="height: 23px;line-height: 21px; text-decoration: underline"
|
style="height: 23px;line-height: 21px; text-decoration: underline"
|
||||||
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 "Remote Backups" %}</span></a>
|
title=""><span>{% trans "Remote Backups" %}</span></a>
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<h3 class="title-hero">
|
<h3 class="title-hero">
|
||||||
{% trans "Create New Backup Schedule" %} <img ng-hide="cyberPanelLoading"
|
{% trans "Create New Backup Schedule" %} <img ng-hide="cyberPanelLoading"
|
||||||
src="{% static 'images/loading.gif' %}">
|
src="{% static 'images/loading.gif' %}" alt="cyberPanelLoading">
|
||||||
</h3>
|
</h3>
|
||||||
<div class="example-box-wrapper">
|
<div class="example-box-wrapper">
|
||||||
|
|
||||||
@@ -61,6 +61,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">{% trans "Select Backup Retention. Leave 0 for no limit" %}</label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<div class="number">
|
||||||
|
<label>
|
||||||
|
<input ng-model="backupRetention" type="number" value="0">
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label"></label>
|
<label class="col-sm-3 control-label"></label>
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
@@ -81,7 +91,7 @@
|
|||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<h3 class="title-hero">
|
<h3 class="title-hero">
|
||||||
{% trans "Manage Existing Back up Schedules" %} <img ng-hide="cyberPanelLoading"
|
{% trans "Manage Existing Back up Schedules" %} <img ng-hide="cyberPanelLoading"
|
||||||
src="{% static 'images/loading.gif' %}">
|
src="{% static 'images/loading.gif' %}" alt="cyberPanelLoading">
|
||||||
</h3>
|
</h3>
|
||||||
<div class="example-box-wrapper">
|
<div class="example-box-wrapper">
|
||||||
|
|
||||||
@@ -133,6 +143,7 @@
|
|||||||
<th>Last Run</th>
|
<th>Last Run</th>
|
||||||
<th>All Sites</th>
|
<th>All Sites</th>
|
||||||
<th>Frequency ({$ currently $})</th>
|
<th>Frequency ({$ currently $})</th>
|
||||||
|
<th>Retention ({$ currently $})</th>
|
||||||
<th>Current Status</th>
|
<th>Current Status</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|||||||
Reference in New Issue
Block a user