mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 22:06:05 +01:00
refactored incBackups
This commit is contained in:
7
IncBackups/IncBackupPath.py
Normal file
7
IncBackups/IncBackupPath.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class IncBackupPath(Enum):
|
||||
SFTP = "/home/cyberpanel/sftp"
|
||||
AWS = "/home/cyberpanel/aws"
|
||||
# WASABI = "/home/cyberpanel/wasabi"
|
||||
8
IncBackups/IncBackupProvider.py
Normal file
8
IncBackups/IncBackupProvider.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from enum import Enum, auto
|
||||
|
||||
|
||||
class IncBackupProvider(Enum):
|
||||
LOCAL = auto()
|
||||
SFTP = auto()
|
||||
AWS = auto()
|
||||
# WASABI = auto()
|
||||
@@ -83,9 +83,7 @@ class IncJobs(multi.Thread):
|
||||
result = self.getRemoteBackups()
|
||||
|
||||
activator = 0
|
||||
json_data = "["
|
||||
checker = 0
|
||||
|
||||
json_data = []
|
||||
if result[0].find('unable to open config file') == -1:
|
||||
for items in reversed(result):
|
||||
|
||||
@@ -98,20 +96,11 @@ class IncJobs(multi.Thread):
|
||||
|
||||
if activator:
|
||||
entry = items.split(' ')
|
||||
|
||||
dic = {'id': entry[0],
|
||||
json_data.append({'id': entry[0],
|
||||
'date': "%s %s" % (entry[2], entry[3]),
|
||||
'host': entry[5],
|
||||
'path': entry[-1]
|
||||
}
|
||||
|
||||
if checker == 0:
|
||||
json_data = json_data + json.dumps(dic)
|
||||
checker = 1
|
||||
else:
|
||||
json_data = json_data + ',' + json.dumps(dic)
|
||||
|
||||
json_data = json_data + ']'
|
||||
})
|
||||
final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ app.controller('createIncrementalBackups', function ($scope, $http, $timeout) {
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
if (response.data.status === 1) {
|
||||
$scope.records = JSON.parse(response.data.data);
|
||||
$scope.records = response.data.data;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
@@ -240,7 +240,7 @@ app.controller('createIncrementalBackups', function ($scope, $http, $timeout) {
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.jobs = JSON.parse(response.data.data);
|
||||
$scope.jobs = response.data.data;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
@@ -358,7 +358,7 @@ app.controller('incrementalDestinations', function ($scope, $http) {
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.records = JSON.parse(response.data.data);
|
||||
$scope.records = response.data.data;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
@@ -621,7 +621,7 @@ app.controller('scheduleBackupInc', function ($scope, $http) {
|
||||
if (response.data.status === 1) {
|
||||
new PNotify({
|
||||
title: 'Success!',
|
||||
text: 'Destination successfully removed.',
|
||||
text: 'Operation successful.',
|
||||
type: 'success'
|
||||
});
|
||||
} else {
|
||||
@@ -668,12 +668,11 @@ app.controller('scheduleBackupInc', function ($scope, $http) {
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.records = JSON.parse(response.data.data);
|
||||
var parsed = JSON.parse(response.data.data);
|
||||
|
||||
for (var j = 0; j < parsed.length; j++) {
|
||||
websitesToBeBackedTemp.push(parsed[j].website);
|
||||
}
|
||||
let data = response.data.data;
|
||||
$scope.records = data;
|
||||
data.forEach(item => {
|
||||
websitesToBeBackedTemp.push(item.website)
|
||||
})
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
@@ -766,7 +765,7 @@ app.controller('scheduleBackupInc', function ($scope, $http) {
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.websites = JSON.parse(response.data.data);
|
||||
$scope.websites = response.data.data;
|
||||
|
||||
if(response.data.websiteData === 1){
|
||||
$scope.websiteData = true;
|
||||
@@ -1074,7 +1073,7 @@ app.controller('restoreRemoteBackupsInc', function ($scope, $http, $timeout) {
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.records = JSON.parse(response.data.data);
|
||||
$scope.records = response.data.data;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
</div>
|
||||
|
||||
<div ng-hide="destination" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Password" %}</label>
|
||||
<label class="col-sm-3 control-label">{% trans "Encrypted Backup Password" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="password" name="password" class="form-control" ng-model="password"
|
||||
required>
|
||||
|
||||
@@ -2,24 +2,24 @@ from django.conf.urls import url
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^createBackup$', views.createBackup, name='createBackupInc'),
|
||||
url(r'^restoreRemoteBackups$', views.restoreRemoteBackups, name='restoreRemoteBackupsInc'),
|
||||
url(r'^backupDestinations$', views.backupDestinations, name='backupDestinationsInc'),
|
||||
url(r'^addDestination$', views.addDestination, name='addDestinationInc'),
|
||||
url(r'^populateCurrentRecords$', views.populateCurrentRecords, name='populateCurrentRecordsInc'),
|
||||
url(r'^removeDestination$', views.removeDestination, name='removeDestinationInc'),
|
||||
url(r'^fetchCurrentBackups$', views.fetchCurrentBackups, name='fetchCurrentBackupsInc'),
|
||||
url(r'^submitBackupCreation$', views.submitBackupCreation, name='submitBackupCreationInc'),
|
||||
url(r'^getBackupStatus$', views.getBackupStatus, name='getBackupStatusInc'),
|
||||
url(r'^deleteBackup$', views.deleteBackup, name='deleteBackupInc'),
|
||||
url(r'^fetchRestorePoints$', views.fetchRestorePoints, name='fetchRestorePointsInc'),
|
||||
url(r'^restorePoint$', views.restorePoint, name='restorePointInc'),
|
||||
url(r'^scheduleBackups$', views.scheduleBackups, name='scheduleBackupsInc'),
|
||||
url(r'^submitBackupSchedule$', views.submitBackupSchedule, name='submitBackupScheduleInc'),
|
||||
url(r'^scheduleDelete$', views.scheduleDelete, name='scheduleDeleteInc'),
|
||||
url(r'^getCurrentBackupSchedules$', views.getCurrentBackupSchedules, name='getCurrentBackupSchedulesInc'),
|
||||
url(r'^fetchSites$', views.fetchSites, name='fetchSites'),
|
||||
url(r'^saveChanges$', views.saveChanges, name='saveChanges'),
|
||||
url(r'^removeSite$', views.removeSite, name='removeSite'),
|
||||
url(r'^addWebsite$', views.addWebsite, name='addWebsite'),
|
||||
url(r'^createBackup$', views.create_backup, name='createBackupInc'),
|
||||
url(r'^restoreRemoteBackups$', views.restore_remote_backups, name='restoreRemoteBackupsInc'),
|
||||
url(r'^backupDestinations$', views.backup_destinations, name='backupDestinationsInc'),
|
||||
url(r'^addDestination$', views.add_destination, name='addDestinationInc'),
|
||||
url(r'^populateCurrentRecords$', views.populate_current_records, name='populateCurrentRecordsInc'),
|
||||
url(r'^removeDestination$', views.remove_destination, name='removeDestinationInc'),
|
||||
url(r'^fetchCurrentBackups$', views.fetch_current_backups, name='fetchCurrentBackupsInc'),
|
||||
url(r'^submitBackupCreation$', views.submit_backup_creation, name='submitBackupCreationInc'),
|
||||
url(r'^getBackupStatus$', views.get_backup_status, name='getBackupStatusInc'),
|
||||
url(r'^deleteBackup$', views.delete_backup, name='deleteBackupInc'),
|
||||
url(r'^fetchRestorePoints$', views.fetch_restore_points, name='fetchRestorePointsInc'),
|
||||
url(r'^restorePoint$', views.restore_point, name='restorePointInc'),
|
||||
url(r'^scheduleBackups$', views.schedule_backups, name='scheduleBackupsInc'),
|
||||
url(r'^submitBackupSchedule$', views.submit_backup_schedule, name='submitBackupScheduleInc'),
|
||||
url(r'^scheduleDelete$', views.schedule_delete, name='scheduleDeleteInc'),
|
||||
url(r'^getCurrentBackupSchedules$', views.get_current_backup_schedules, name='getCurrentBackupSchedulesInc'),
|
||||
url(r'^fetchSites$', views.fetch_sites, name='fetchSites'),
|
||||
url(r'^saveChanges$', views.save_changes, name='saveChanges'),
|
||||
url(r'^removeSite$', views.remove_site, name='removeSite'),
|
||||
url(r'^addWebsite$', views.add_website, name='addWebsite'),
|
||||
]
|
||||
File diff suppressed because it is too large
Load Diff
@@ -101,7 +101,7 @@ app.controller('createIncrementalBackups', function ($scope, $http, $timeout) {
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
if (response.data.status === 1) {
|
||||
$scope.records = JSON.parse(response.data.data);
|
||||
$scope.records = response.data.data;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
@@ -240,7 +240,7 @@ app.controller('createIncrementalBackups', function ($scope, $http, $timeout) {
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.jobs = JSON.parse(response.data.data);
|
||||
$scope.jobs = response.data.data;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
@@ -358,7 +358,7 @@ app.controller('incrementalDestinations', function ($scope, $http) {
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.records = JSON.parse(response.data.data);
|
||||
$scope.records = response.data.data;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
@@ -621,7 +621,7 @@ app.controller('scheduleBackupInc', function ($scope, $http) {
|
||||
if (response.data.status === 1) {
|
||||
new PNotify({
|
||||
title: 'Success!',
|
||||
text: 'Destination successfully removed.',
|
||||
text: 'Operation successful.',
|
||||
type: 'success'
|
||||
});
|
||||
} else {
|
||||
@@ -668,12 +668,11 @@ app.controller('scheduleBackupInc', function ($scope, $http) {
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.records = JSON.parse(response.data.data);
|
||||
var parsed = JSON.parse(response.data.data);
|
||||
|
||||
for (var j = 0; j < parsed.length; j++) {
|
||||
websitesToBeBackedTemp.push(parsed[j].website);
|
||||
}
|
||||
let data = response.data.data;
|
||||
$scope.records = data;
|
||||
data.forEach(item => {
|
||||
websitesToBeBackedTemp.push(item.website)
|
||||
})
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
@@ -766,7 +765,7 @@ app.controller('scheduleBackupInc', function ($scope, $http) {
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.websites = JSON.parse(response.data.data);
|
||||
$scope.websites = response.data.data;
|
||||
|
||||
if(response.data.websiteData === 1){
|
||||
$scope.websiteData = true;
|
||||
@@ -1074,7 +1073,7 @@ app.controller('restoreRemoteBackupsInc', function ($scope, $http, $timeout) {
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.records = JSON.parse(response.data.data);
|
||||
$scope.records = response.data.data;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
|
||||
Reference in New Issue
Block a user