mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-06-09 16:02:48 +02:00
bug fix: add retention to rustic backups
This commit is contained in:
@@ -2027,7 +2027,8 @@ app.controller('ScheduleV2Backup', function ($scope, $http, $timeout, $compile)
|
||||
frequency: $scope.frequency,
|
||||
websiteData: $scope.websiteData,
|
||||
websiteDatabases: $scope.websiteDatabases,
|
||||
websiteEmails: $scope.websiteEmails
|
||||
websiteEmails: $scope.websiteEmails,
|
||||
retention: $scope.retention
|
||||
};
|
||||
//alert( $scope.selwebsite);
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<div ng-controller="CreateV2Backup" class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="title-hero">
|
||||
{% trans "Create v2 Backup" %} <img ng-hide="backupLoading" src="{% static 'images/loading.gif' %}">
|
||||
{% trans "Create v2 Backup" %} <img ng-hide="backupLoading" src="{% static 'images/loading.gif' %}"> - <a href="{% url 'RestoreV2backupSite' %}">Restore Backups</a>
|
||||
</h3>
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Select Website" %} </label>
|
||||
<label class="col-sm-3 control-label">{% trans "Backup Frequency" %} </label>
|
||||
<div class="col-sm-6">
|
||||
<select id="create-backup-select" ng-model="frequency"
|
||||
class="form-control">
|
||||
@@ -65,6 +65,17 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Backup Retention" %} </label>
|
||||
<div class="col-sm-6">
|
||||
<select id="create-backup-select" ng-model="retention"
|
||||
class="form-control">
|
||||
<option value="1">1 Day</option>
|
||||
<option value="3">3 Days</option>
|
||||
<option value="30">30 Days</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Backup Content" %}</label>
|
||||
<div class="col-sm-9">
|
||||
@@ -125,6 +136,7 @@
|
||||
<tr>
|
||||
<th>{% trans "Repo" %}</th>
|
||||
<th>{% trans "Frequency" %}</th>
|
||||
<th>{% trans "Retention" %}</th>
|
||||
<th>{% trans "Backup Websites?" %}</th>
|
||||
<th>{% trans "Backup Databases?" %}</th>
|
||||
<th>{% trans "Backup Emails?" %}</th>
|
||||
@@ -136,6 +148,7 @@
|
||||
<tr ng-repeat="record in records track by $index">
|
||||
<td ng-bind="record.repo"></td>
|
||||
<td ng-bind="record.frequency"></td>
|
||||
<td ng-bind="record.retention"></td>
|
||||
<td ng-bind="record.websiteData"></td>
|
||||
<td ng-bind="record.websiteDatabases"></td>
|
||||
<td ng-bind="record.websiteEmails"></td>
|
||||
|
||||
@@ -1122,9 +1122,10 @@ def CreateScheduleV2(request):
|
||||
Selectedwebsite = data['Selectedwebsite']
|
||||
repo = data['repo']
|
||||
frequency = data['frequency']
|
||||
websiteData = data['websiteData']
|
||||
websiteDatabases = data['websiteDatabases']
|
||||
websiteEmails = data['websiteEmails']
|
||||
retention = data['retention']
|
||||
websiteData = data['websiteData'] if 'websiteData' in data else False
|
||||
websiteDatabases = data['websiteDatabases'] if 'websiteDatabases' in data else False
|
||||
websiteEmails = data['websiteEmails'] if 'websiteEmails' in data else False
|
||||
|
||||
#
|
||||
# extra_args['BackupData'] = data['websiteData'] if 'websiteData' in data else False
|
||||
@@ -1140,7 +1141,7 @@ def CreateScheduleV2(request):
|
||||
return ACLManager.loadError()
|
||||
|
||||
|
||||
status, message = CPBackupsV2.CreateScheduleV2(Selectedwebsite, repo, frequency, websiteData, websiteDatabases, websiteEmails)
|
||||
status, message = CPBackupsV2.CreateScheduleV2(Selectedwebsite, repo, frequency, websiteData, websiteDatabases, websiteEmails, retention)
|
||||
|
||||
final_dic = {'status': 1, 'error_message': message}
|
||||
final_json = json.dumps(final_dic)
|
||||
|
||||
@@ -335,7 +335,8 @@
|
||||
data-original-title=".icon-cloud-upload" aria-describedby="tooltip896208"></i>
|
||||
<span>{% trans "Connect" %}</span>
|
||||
</a>
|
||||
<a id="sidebar-menu-item-community" target="_blank" href="https://go.cyberpanel.net/community"
|
||||
<a id="sidebar-menu-item-community" target="_blank"
|
||||
href="https://go.cyberpanel.net/community"
|
||||
title="{% trans 'Connect' %}">
|
||||
<i class="glyph-icon tooltip-button icon-comments-o" title="{% trans 'Community' %}"
|
||||
data-original-title=".icon-comments-alt" aria-describedby="tooltip896208"></i>
|
||||
@@ -397,7 +398,7 @@
|
||||
</div><!-- .sidebar-submenu -->
|
||||
</li>
|
||||
|
||||
<!-------------WordPress--------------------------->
|
||||
<!-------------WordPress--------------------------->
|
||||
<li id="sidebar-menu-item-wordpress">
|
||||
<a href="{% url 'loadWebsitesHome' %}" title="{% trans 'WordPress' %}">
|
||||
<div class="glyph-icon icon-wordpress" title="{% trans 'WordPress' %}"></div>
|
||||
@@ -680,18 +681,15 @@
|
||||
<div class="sidebar-submenu">
|
||||
|
||||
<ul>
|
||||
<li><a href="{% url 'CreateV2Backup' %}"
|
||||
title="{% trans "Create V2 Backup" %}"><span>{% trans "Create V2 Backup" %}</span></a>
|
||||
</li>
|
||||
<li><a href="{% url 'ConfigureV2Backup' %}"
|
||||
title="{% trans "Configure V2 Backup" %}"><span>{% trans "Configure V2 Backup" %}</span></a>
|
||||
</li>
|
||||
<li><a href="{% url 'RestoreV2backupSite' %}"
|
||||
title="{% trans "Restore V2 Backup" %}"><span>{% trans "Restore V2 Backup" %}</span></a>
|
||||
</li>
|
||||
<li><a href="{% url 'CreateV2Backup' %}"
|
||||
title="{% trans "Create V2 Backup" %}"><span>{% trans "Create/Restore V2 Backup" %}</span></a>
|
||||
</li>
|
||||
<li><a href="{% url 'ConfigureV2Backup' %}"
|
||||
title="{% trans "Configure Backends" %}"><span>{% trans "Configure Backends" %}</span></a>
|
||||
</li>
|
||||
<li><a href="{% url 'schedulev2Backups' %}"
|
||||
title="{% trans "Schedule V2 Backup" %}"><span>{% trans "Schedule V2 Backup" %}</span></a>
|
||||
</li>
|
||||
title="{% trans "Schedule V2 Backup" %}"><span>{% trans "Schedule V2 Backup" %}</span></a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -743,7 +743,10 @@ token = {token}
|
||||
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)
|
||||
result = ProcessUtilities.outputExecutioner(command, self.website.externalApp, True)
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.CyberCPLogFileWriter.writeToFile(result)
|
||||
|
||||
@staticmethod
|
||||
def FetchCurrentSchedules(website):
|
||||
@@ -759,10 +762,16 @@ token = {token}
|
||||
schedules = []
|
||||
for value in BackupConfig['schedules']:
|
||||
|
||||
schedules.append({'repo': value['repo'], 'frequency': value['frequency'], 'websiteData': value['websiteData'],
|
||||
schedules.append({
|
||||
'repo': value['repo'],
|
||||
'frequency': value['frequency'],
|
||||
'websiteData': value['websiteData'],
|
||||
'websiteEmails': value['websiteEmails'],
|
||||
'websiteDatabases': value['websiteDatabases'], 'lastRun': value['lastRun'],
|
||||
'domain': website})
|
||||
'websiteDatabases': value['websiteDatabases'],
|
||||
'lastRun': value['lastRun'],
|
||||
'retention': value['retention'],
|
||||
'domain': website
|
||||
})
|
||||
|
||||
return 1, schedules
|
||||
else:
|
||||
@@ -805,7 +814,7 @@ token = {token}
|
||||
return 0, str(msg)
|
||||
|
||||
@staticmethod
|
||||
def CreateScheduleV2(website, repo, frequency, websiteData, websiteDatabases, websiteEmails):
|
||||
def CreateScheduleV2(website, repo, frequency, websiteData, websiteDatabases, websiteEmails, retention):
|
||||
try:
|
||||
|
||||
finalConfigPath = f'/home/cyberpanel/v2backups/{website}'
|
||||
@@ -819,11 +828,11 @@ token = {token}
|
||||
BackupConfig = json.loads(ProcessUtilities.outputExecutioner(command).rstrip('\n'))
|
||||
|
||||
try:
|
||||
BackupConfig['schedules'].append({"repo": repo, "retention": "7", "frequency": frequency, "websiteData": websiteData,
|
||||
BackupConfig['schedules'].append({"repo": repo, "retention": retention, "frequency": frequency, "websiteData": websiteData,
|
||||
"websiteEmails": websiteEmails, "websiteDatabases": websiteDatabases,
|
||||
"lastRun": ""})
|
||||
except:
|
||||
BackupConfig['schedules'] = [{"repo": repo, "retention": "7", "frequency": frequency, "websiteData": websiteData,
|
||||
BackupConfig['schedules'] = [{"repo": repo, "retention": retention, "frequency": frequency, "websiteData": websiteData,
|
||||
"websiteEmails": websiteEmails, "websiteDatabases": websiteDatabases,
|
||||
"lastRun": ""}]
|
||||
|
||||
@@ -839,7 +848,7 @@ token = {token}
|
||||
else:
|
||||
BackupConfig = {'site': website,
|
||||
'schedules':
|
||||
[{"repo": repo, "retention": "7", "frequency": frequency,
|
||||
[{"repo": repo, "retention": retention, "frequency": frequency,
|
||||
"websiteData": websiteData,
|
||||
"websiteEmails": websiteEmails, "websiteDatabases": websiteDatabases,
|
||||
"lastRun": ""}]}
|
||||
|
||||
@@ -1449,6 +1449,8 @@ Automatic Backupv2 failed for %s on %s.
|
||||
logging.SendEmail(sender, TO, message)
|
||||
else:
|
||||
value['lastRun'] = time.strftime("%m.%d.%Y_%H-%M-%S")
|
||||
|
||||
background.DeleteSnapshots(f"--keep-daily {value['retention']}")
|
||||
except BaseException as msg:
|
||||
print("Error: [v2Backups]: %s" % str(msg))
|
||||
logging.writeToFile('%s. [v2Backups]' % (str(msg)))
|
||||
|
||||
Reference in New Issue
Block a user