mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-05 04:46:07 +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 websiteFunctions.models import Websites
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class IncJob(models.Model):
|
||||
website = models.ForeignKey(Websites, on_delete=models.CASCADE)
|
||||
date = models.DateTimeField(default=datetime.now, blank=True)
|
||||
|
||||
|
||||
class JobSnapshots(models.Model):
|
||||
job = models.ForeignKey(IncJob, on_delete=models.CASCADE)
|
||||
type = models.CharField(max_length=300)
|
||||
@@ -21,10 +21,9 @@ class BackupJob(models.Model):
|
||||
websiteData = models.IntegerField()
|
||||
websiteDatabases = models.IntegerField()
|
||||
websiteDataEmails = models.IntegerField()
|
||||
retention = models.IntegerField()
|
||||
|
||||
|
||||
class JobSites(models.Model):
|
||||
job = models.ForeignKey(BackupJob, on_delete=models.CASCADE)
|
||||
website = models.CharField(max_length=300)
|
||||
|
||||
|
||||
|
||||
@@ -599,6 +599,7 @@ app.controller('scheduleBackupInc', function ($scope, $http) {
|
||||
var data = {
|
||||
backupDestinations: $scope.backupDest,
|
||||
backupFreq: $scope.backupFreq,
|
||||
backupRetention: $scope.backupRetention,
|
||||
websiteData: $scope.websiteData,
|
||||
websiteEmails: $scope.websiteEmails,
|
||||
websiteDatabases: $scope.websiteDatabases,
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
<div class="container">
|
||||
<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;"
|
||||
class="btn btn-border btn-alt border-red btn-link font-red"
|
||||
title=""><span>{% trans "Remote Backups" %}</span></a></h2>
|
||||
@@ -50,6 +50,18 @@
|
||||
</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">
|
||||
<label class="col-sm-3 control-label">{% trans "Backup Content" %}</label>
|
||||
<div class="col-sm-9">
|
||||
|
||||
@@ -524,6 +524,7 @@ def submit_backup_schedule(request):
|
||||
|
||||
backup_dest = data['backupDestinations']
|
||||
backup_freq = data['backupFreq']
|
||||
backup_retention = data['backupRetention']
|
||||
backup_sites = data['websitesToBeBacked']
|
||||
|
||||
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_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()
|
||||
|
||||
for site in backup_sites:
|
||||
@@ -558,6 +560,7 @@ def get_current_backup_schedules(request):
|
||||
json_data.append({'id': items.id,
|
||||
'destination': items.destination,
|
||||
'frequency': items.frequency,
|
||||
'retention': items.retention,
|
||||
'numberOfSites': items.jobsites_set.all().count()
|
||||
})
|
||||
final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data})
|
||||
|
||||
@@ -886,6 +886,7 @@ class BackupManager:
|
||||
selectedAccount = data['selectedAccount']
|
||||
name = data['name']
|
||||
backupFrequency = data['backupFrequency']
|
||||
backupRetention = data['backupRetention']
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
@@ -894,7 +895,8 @@ class BackupManager:
|
||||
|
||||
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.save()
|
||||
@@ -1465,6 +1467,11 @@ class BackupManager:
|
||||
except:
|
||||
frequency = 'Never'
|
||||
|
||||
try:
|
||||
retention = config[IncScheduler.retention]
|
||||
except:
|
||||
retention = 'Never'
|
||||
|
||||
try:
|
||||
currentStatus = config[IncScheduler.currentStatus]
|
||||
except:
|
||||
@@ -1615,6 +1622,7 @@ class BackupManager:
|
||||
|
||||
selectedJob = data['selectedJob']
|
||||
backupFrequency = data['backupFrequency']
|
||||
backupRetention = data['backupRetention']
|
||||
|
||||
nbj = NormalBackupJobs.objects.get(name=selectedJob)
|
||||
|
||||
@@ -1623,6 +1631,7 @@ class BackupManager:
|
||||
|
||||
config = json.loads(nbj.config)
|
||||
config[IncScheduler.frequency] = backupFrequency
|
||||
config[IncScheduler.retention] = backupRetention
|
||||
|
||||
nbj.config = json.dumps(config)
|
||||
nbj.save()
|
||||
|
||||
@@ -1247,7 +1247,8 @@ app.controller('googleDrive', function ($scope, $http) {
|
||||
};
|
||||
var data = {
|
||||
selectedAccount: $scope.selectedAccount,
|
||||
backupFrequency: $scope.backupFrequency
|
||||
backupFrequency: $scope.backupFrequency,
|
||||
backupRetention: $scope.backupRetention,
|
||||
};
|
||||
|
||||
dataurl = "/backup/changeAccountFrequencygDrive";
|
||||
@@ -1654,7 +1655,8 @@ app.controller('scheduleBackup', function ($scope, $http, $window) {
|
||||
var data = {
|
||||
selectedAccount: $scope.selectedAccountAdd,
|
||||
name: $scope.name,
|
||||
backupFrequency: $scope.backupFrequency
|
||||
backupFrequency: $scope.backupFrequency,
|
||||
backupRetention: $scope.backupRetention,
|
||||
};
|
||||
|
||||
dataurl = "/backup/submitBackupSchedule";
|
||||
@@ -1856,7 +1858,8 @@ app.controller('scheduleBackup', function ($scope, $http, $window) {
|
||||
};
|
||||
var data = {
|
||||
selectedJob: $scope.selectedJob,
|
||||
backupFrequency: $scope.backupFrequency
|
||||
backupFrequency: $scope.backupFrequency,
|
||||
backupRetention: $scope.backupRetention,
|
||||
};
|
||||
|
||||
dataurl = "/backup/changeAccountFrequencyNormal";
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<div ng-controller="scheduleBackup" class="container">
|
||||
<div id="page-title">
|
||||
<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"
|
||||
class="btn btn-border btn-alt border-red btn-link font-red"
|
||||
title=""><span>{% trans "Remote Backups" %}</span></a>
|
||||
@@ -24,7 +24,7 @@
|
||||
<div class="panel-body">
|
||||
<h3 class="title-hero">
|
||||
{% trans "Create New Backup Schedule" %} <img ng-hide="cyberPanelLoading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
src="{% static 'images/loading.gif' %}" alt="cyberPanelLoading">
|
||||
</h3>
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
@@ -61,6 +61,16 @@
|
||||
</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">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
@@ -81,7 +91,7 @@
|
||||
<div class="panel-body">
|
||||
<h3 class="title-hero">
|
||||
{% trans "Manage Existing Back up Schedules" %} <img ng-hide="cyberPanelLoading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
src="{% static 'images/loading.gif' %}" alt="cyberPanelLoading">
|
||||
</h3>
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
@@ -133,6 +143,7 @@
|
||||
<th>Last Run</th>
|
||||
<th>All Sites</th>
|
||||
<th>Frequency ({$ currently $})</th>
|
||||
<th>Retention ({$ currently $})</th>
|
||||
<th>Current Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
Reference in New Issue
Block a user