mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 22:06:05 +01:00
backupconfig
This commit is contained in:
@@ -418,6 +418,9 @@
|
||||
<li><a href="{% url 'RestoreBackups' %}"
|
||||
title="{% trans 'RestoreBackups' %}"><span>{% trans "Restore Backups" %}</span></a>
|
||||
</li>
|
||||
<li><a href="{% url 'RemoteBackupConfig' %}"
|
||||
title="{% trans 'Remote Backup' %}"><span>{% trans "Remote Backup" %}</span></a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div><!-- .sidebar-submenu -->
|
||||
|
||||
@@ -128,3 +128,22 @@ class WPSitesBackup(models.Model):
|
||||
WPSiteID = models.IntegerField(default=-1)
|
||||
WebsiteID = models.IntegerField(default=-1)
|
||||
config = models.TextField()
|
||||
|
||||
|
||||
class RemoteBackupConfig(models.Model):
|
||||
owner = models.ForeignKey(Administrator, on_delete=models.CASCADE)
|
||||
configtype = models.CharField(max_length=255, default='')
|
||||
config = models.TextField()
|
||||
|
||||
class RemoteBackupSchedule(models.Model):
|
||||
RemoteBackupConfig = models.ForeignKey(RemoteBackupConfig, on_delete=models.CASCADE)
|
||||
Name = models.CharField(max_length=255, default='')
|
||||
timeintervel = models.CharField(max_length=200)
|
||||
fileretention = models.CharField(max_length=200)
|
||||
lastrun = models.CharField(max_length=200)
|
||||
config = models.TextField()
|
||||
|
||||
class RemoteBackupsites(models.Model):
|
||||
owner = models.ForeignKey(RemoteBackupSchedule, on_delete=models.CASCADE)
|
||||
WPsites = models.IntegerField(null=True)
|
||||
database = models.IntegerField(null=True)
|
||||
|
||||
@@ -589,8 +589,7 @@ app.controller('WPsiteHome', function ($scope, $http, $timeout, $compile, $windo
|
||||
PPPassword: $scope.PPPassword,
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
var data = {
|
||||
WPid: $('#WPid').html(),
|
||||
setting: setting,
|
||||
@@ -1955,6 +1954,217 @@ app.controller('RestoreWPBackup', function ($scope, $http, $timeout, $window) {
|
||||
});
|
||||
|
||||
|
||||
//.......................................Remote Backup
|
||||
|
||||
//........... delete DeleteBackupConfigNow
|
||||
|
||||
function DeleteBackupConfigNow(url) {
|
||||
window.location.href = url;
|
||||
}
|
||||
function DeleteRemoteBackupsiteNow(url) {
|
||||
window.location.href = url;
|
||||
}
|
||||
function DeleteBackupfileConfigNow(url) {
|
||||
window.location.href = url;
|
||||
}
|
||||
|
||||
|
||||
app.controller('RemoteBackupConfig', function ($scope, $http, $timeout, $window) {
|
||||
$scope.RemoteBackupLoading = true;
|
||||
$scope.SFTPBackUpdiv = true;
|
||||
$scope.S3backupdiv = true;
|
||||
$scope.SelectRemoteBackuptype = function () {
|
||||
var val = $scope.RemoteBackuptype;
|
||||
if (val == "SFTP") {
|
||||
$scope.SFTPBackUpdiv = false;
|
||||
$scope.S3backupdiv = true;
|
||||
} else {
|
||||
$scope.S3backupdiv = false;
|
||||
$scope.SFTPBackUpdiv = true;
|
||||
}
|
||||
}
|
||||
|
||||
$scope.SaveBackupConfig = function () {
|
||||
$scope.RemoteBackupLoading = false;
|
||||
var Hname = $scope.Hostname;
|
||||
var Uname = $scope.Username;
|
||||
var Passwd = $scope.Password;
|
||||
var path = $scope.path;
|
||||
var type = $scope.RemoteBackuptype;
|
||||
|
||||
if (type == "SFTP") {
|
||||
|
||||
var data = {
|
||||
Hname: Hname,
|
||||
Uname: Uname,
|
||||
Passwd: Passwd,
|
||||
path: path,
|
||||
type: type
|
||||
}
|
||||
var url = "/websites/SaveBackupConfig";
|
||||
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.RemoteBackupLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
new PNotify({
|
||||
title: 'Success!',
|
||||
text: 'Successfully Saved!.',
|
||||
type: 'success'
|
||||
});
|
||||
location.reload();
|
||||
|
||||
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.RemoteBackupLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
app.controller('BackupSchedule', function ($scope, $http, $timeout, $window) {
|
||||
$scope.BackupScheduleLoading = true;
|
||||
$scope.SaveBackupSchedule = function () {
|
||||
$scope.RemoteBackupLoading = false;
|
||||
var FileRetention = $scope.Fretention;
|
||||
var Backfrequency = $scope.Bfrequency;
|
||||
|
||||
|
||||
var data = {
|
||||
FileRetention: FileRetention,
|
||||
Backfrequency: Backfrequency,
|
||||
ScheduleName: $scope.ScheduleName,
|
||||
RemoteConfigID : $('#RemoteConfigID').html(),
|
||||
BackupType: $scope.BackupType
|
||||
}
|
||||
var url = "/websites/SaveBackupSchedule";
|
||||
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.RemoteBackupLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
new PNotify({
|
||||
title: 'Success!',
|
||||
text: 'Successfully Saved!.',
|
||||
type: 'success'
|
||||
});
|
||||
location.reload();
|
||||
|
||||
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.RemoteBackupLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$scope.AddWPsiteforRemoteBackup = function () {
|
||||
$scope.RemoteBackupLoading = false;
|
||||
|
||||
|
||||
|
||||
var data = {
|
||||
WpsiteID: $('#Wpsite').val(),
|
||||
RemoteScheduleID : $('#RemoteScheduleID').html()
|
||||
}
|
||||
var url = "/websites/AddWPsiteforRemoteBackup";
|
||||
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.RemoteBackupLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
new PNotify({
|
||||
title: 'Success!',
|
||||
text: 'Successfully Saved!.',
|
||||
type: 'success'
|
||||
});
|
||||
location.reload();
|
||||
|
||||
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.RemoteBackupLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
/* Java script code to create account */
|
||||
app.controller('createWebsite', function ($scope, $http, $timeout, $window) {
|
||||
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Backup Sites Configurations - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Backup Sites Configurations" %}</h2>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-controller="BackupSchedule" class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="content-box-header">
|
||||
{% trans " Add WordPress Sites for Remote Backup" %} <img ng-hide="BackupScheduleLoading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</h3>
|
||||
<form name="websiteCreationForm" action="/" id="createPackages"
|
||||
class="form-horizontal bordered-row panel-body">
|
||||
|
||||
<span style="display: none" id="RemoteScheduleID"> {{ RemoteScheduleID }}</span>
|
||||
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Selecte WordPress Site" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<select ng-model="Wpsite" id="Wpsite"
|
||||
class="form-control">
|
||||
{% for i in WPsites %}
|
||||
<option value="{{ i.id }}">{{ i.title }}</option>
|
||||
{% endfor %}
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="AddWPsiteforRemoteBackup()"
|
||||
class="btn btn-primary btn-lg">{% trans "Save Backup Schedule" %}</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<h3 class="content-box-header">
|
||||
{% trans "Saved Sites For Remote Backup" %} </h3>
|
||||
<table class="table-spacing" style="width: 100%">
|
||||
<thead style="color: white; background-color: #0a6ebd">
|
||||
<tr>
|
||||
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">ID</th>
|
||||
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">WordPress Title</th>
|
||||
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{% for sub in RemoteBackupsites %}
|
||||
<tr>
|
||||
<td style="padding: 13px;">{{ sub.id }}</td>
|
||||
<td style="padding: 13px;">{{ sub.Title }}</td>
|
||||
<td style="padding: 13px;">
|
||||
<button
|
||||
aria-label=""
|
||||
onclick="DeleteRemoteBackupsiteNow('{% url 'AddRemoteBackupsite' %}?ID={{ RemoteScheduleID }}&DeleteID={{ sub.id }}')"
|
||||
type="button" class="btn btn-border btn-alt border-red btn-link font-red">
|
||||
Delete
|
||||
</button>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,127 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "File Config - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Backup File Configurations" %}</h2>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-controller="BackupSchedule" class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="content-box-header">
|
||||
{% trans " Schedule Backups" %} <img ng-hide="BackupScheduleLoading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</h3>
|
||||
<form name="websiteCreationForm" action="/" id="createPackages"
|
||||
class="form-horizontal bordered-row panel-body">
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Schedule Name" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="Hostname" type="text" class="form-control" ng-model="ScheduleName"
|
||||
required>
|
||||
</div>
|
||||
</div>
|
||||
<span style="display: none" id="RemoteConfigID"> {{ RemoteConfigID }}</span>
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Backup Frequency" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<select ng-model="Bfrequency"
|
||||
class="form-control">
|
||||
<option>30 Minutes</option>
|
||||
<option>1 Hour</option>
|
||||
<option>6 Hours</option>
|
||||
<option>12 Hours</option>
|
||||
<option>1 Day</option>
|
||||
<option>3 Days</option>
|
||||
<option>1 Week</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Backup File Retention" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<select ng-model="Fretention"
|
||||
class="form-control">
|
||||
<option>3 Days</option>
|
||||
<option>1 Week</option>
|
||||
<option>3 Weeks</option>
|
||||
<option>1 Month</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Back Type" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<select ng-model="BackupType"
|
||||
class="form-control">
|
||||
<option>Only DataBase</option>
|
||||
<option>Only Website</option>
|
||||
<option>Website and Database Both</option>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="SaveBackupSchedule()"
|
||||
class="btn btn-primary btn-lg">{% trans "Save Backup Schedule" %}</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<h3 class="content-box-header">
|
||||
{% trans "Configure Backup Schedules" %} </h3>
|
||||
<table class="table-spacing" style="width: 100%">
|
||||
<thead style="color: white; background-color: #0a6ebd">
|
||||
<tr>
|
||||
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">ID</th>
|
||||
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Schedule Name</th>
|
||||
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Remote Configuration
|
||||
</th>
|
||||
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{% for sub in Backupschedule %}
|
||||
<tr>
|
||||
<td style="padding: 13px;">{{ sub.id }}</td>
|
||||
<td style="padding: 13px;">{{ sub.Name }}</td>
|
||||
<td style="padding: 13px;">{{ sub.RemoteConfiguration }}</td>
|
||||
<td style="padding: 13px;">
|
||||
<button
|
||||
aria-label=""
|
||||
onclick="DeleteBackupfileConfigNow('{% url 'BackupfileConfig' %}?ID={{ RemoteConfigID }}&DeleteID={{ sub.id }}')"
|
||||
type="button" class="btn btn-border btn-alt border-red btn-link font-red">
|
||||
Delete
|
||||
</button>
|
||||
<a href="{% url 'AddRemoteBackupsite' %}?ID={{ sub.id }}"
|
||||
aria-label=""
|
||||
|
||||
type="button" class="btn btn-border btn-alt border-green btn-link font-green">
|
||||
Add WordPress Sites
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,131 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Remote Backup Configurations - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Remote Backup Configurations" %}</h2>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-controller="RemoteBackupConfig" class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="content-box-header">
|
||||
{% trans "Configure Remote Backups" %} <img ng-hide="RemoteBackupLoading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</h3>
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
<form name="websiteCreationForm" action="/" id="createPackages"
|
||||
class="form-horizontal bordered-row panel-body">
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Select Remote Backup Type" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<select ng-model="RemoteBackuptype" ng-change="SelectRemoteBackuptype()"
|
||||
class="form-control">
|
||||
<option>SFTP</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="SFTPBackUpdiv" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Hostname" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="Hostname" type="text" class="form-control" ng-model="Hostname"
|
||||
required>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div ng-hide="SFTPBackUpdiv" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Username" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="Username" type="text" class="form-control" ng-model="Username"
|
||||
required>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div ng-hide="SFTPBackUpdiv" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Password" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="Password" type="password" class="form-control" ng-model="Password"
|
||||
required>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div ng-hide="SFTPBackUpdiv" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "path" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="path" type="path" class="form-control" ng-model="path"
|
||||
required>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div ng-hide="S3backupdiv">
|
||||
<span>S3 BAckups</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="SaveBackupConfig()"
|
||||
class="btn btn-primary btn-lg">{% trans "Save Configurations" %}</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<h3 class="content-box-header">
|
||||
{% trans "Saved Remote Configuration" %} </h3>
|
||||
<table class="table-spacing" style="width: 100%">
|
||||
<thead style="color: white; background-color: #0a6ebd">
|
||||
<tr>
|
||||
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Backup Type</th>
|
||||
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">HostName</th>
|
||||
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Path</th>
|
||||
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody >
|
||||
{% for sub in backupconfigs %}
|
||||
<tr>
|
||||
<td style="padding: 13px;">{{ sub.Type }}</td>
|
||||
<td style="padding: 13px;">{{ sub.HostName }}</td>
|
||||
<td style="padding: 13px;">{{ sub.Path }}</td>
|
||||
<td style="padding: 13px;"> <button
|
||||
aria-label=""
|
||||
onclick="DeleteBackupConfigNow('{% url 'RemoteBackupConfig' %}?DeleteID={{ sub.id }}')"
|
||||
type="button" class="btn btn-border btn-alt border-red btn-link font-red">
|
||||
Delete
|
||||
</button>
|
||||
<a href="{% url 'BackupfileConfig' %}?ID={{ sub.id }}"
|
||||
aria-label=""
|
||||
|
||||
type="button" class="btn btn-border btn-alt border-green btn-link font-green">
|
||||
Schedule Backups
|
||||
</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
@@ -23,6 +23,9 @@ urlpatterns = [
|
||||
url(r'^RestoreBackups$', views.RestoreBackups, name='RestoreBackups'),
|
||||
url(r'^RestoreHome$', views.RestoreHome, name='RestoreHome'),
|
||||
url(r'^AutoLogin$', views.AutoLogin, name='AutoLogin'),
|
||||
url(r'^RemoteBackupConfig$', views.RemoteBackupConfig, name='RemoteBackupConfig'),
|
||||
url(r'^BackupfileConfig$', views.BackupfileConfig, name='BackupfileConfig'),
|
||||
url(r'^AddRemoteBackupsite$', views.AddRemoteBackupsite, name='AddRemoteBackupsite'),
|
||||
|
||||
|
||||
###WordPress Ajax
|
||||
@@ -44,9 +47,11 @@ urlpatterns = [
|
||||
url(r'^DeploytoProduction', views.DeploytoProduction, name='DeploytoProduction'),
|
||||
url(r'^WPCreateBackup', views.WPCreateBackup, name='WPCreateBackup'),
|
||||
url(r'^RestoreWPbackupNow', views.RestoreWPbackupNow, name='RestoreWPbackupNow'),
|
||||
url(r'^RestoreWPbackupNow', views.RestoreWPbackupNow, name='RestoreWPbackupNow'),
|
||||
url(r'^dataintegrity', views.dataintegrity, name='dataintegrity'),
|
||||
url(r'^installwpcore', views.installwpcore, name='installwpcore'),
|
||||
url(r'^SaveBackupConfig', views.SaveBackupConfig, name='SaveBackupConfig'),
|
||||
url(r'^SaveBackupSchedule', views.SaveBackupSchedule, name='SaveBackupSchedule'),
|
||||
url(r'^AddWPsiteforRemoteBackup', views.AddWPsiteforRemoteBackup, name='AddWPsiteforRemoteBackup'),
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -65,6 +65,40 @@ def RestoreHome(request):
|
||||
return wm.RestoreHome(request, userID, BackupID)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def RemoteBackupConfig(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
DeleteID = request.GET.get('DeleteID')
|
||||
wm = WebsiteManager()
|
||||
return wm.RemoteBackupConfig(request, userID, DeleteID)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def BackupfileConfig(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
ID = request.GET.get('ID')
|
||||
DeleteID = request.GET.get('DeleteID')
|
||||
wm = WebsiteManager()
|
||||
return wm.BackupfileConfig(request, userID, ID, DeleteID)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def AddRemoteBackupsite(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
ID = request.GET.get('ID')
|
||||
DeleteSiteID = request.GET.get('DeleteID')
|
||||
wm = WebsiteManager()
|
||||
return wm.AddRemoteBackupsite(request, userID, ID,DeleteSiteID )
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def RestoreBackups(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -407,6 +441,67 @@ def RestoreWPbackupNow(request):
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def SaveBackupConfig(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
result = pluginManager.preWebsiteCreation(request)
|
||||
if result != 200:
|
||||
return result
|
||||
|
||||
wm = WebsiteManager()
|
||||
coreResult = wm.SaveBackupConfig(userID, json.loads(request.body))
|
||||
|
||||
result = pluginManager.postWebsiteCreation(request, coreResult)
|
||||
if result != 200:
|
||||
return result
|
||||
|
||||
return coreResult
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def SaveBackupSchedule(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
result = pluginManager.preWebsiteCreation(request)
|
||||
if result != 200:
|
||||
return result
|
||||
|
||||
wm = WebsiteManager()
|
||||
coreResult = wm.SaveBackupSchedule(userID, json.loads(request.body))
|
||||
|
||||
result = pluginManager.postWebsiteCreation(request, coreResult)
|
||||
if result != 200:
|
||||
return result
|
||||
|
||||
return coreResult
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def AddWPsiteforRemoteBackup(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
result = pluginManager.preWebsiteCreation(request)
|
||||
if result != 200:
|
||||
return result
|
||||
|
||||
wm = WebsiteManager()
|
||||
coreResult = wm.AddWPsiteforRemoteBackup(userID, json.loads(request.body))
|
||||
|
||||
result = pluginManager.postWebsiteCreation(request, coreResult)
|
||||
if result != 200:
|
||||
return result
|
||||
|
||||
return coreResult
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def installwpcore(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
@@ -4,6 +4,7 @@ import os.path
|
||||
import sys
|
||||
import django
|
||||
|
||||
from databases.models import Databases
|
||||
from plogical.httpProc import httpProc
|
||||
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
@@ -12,7 +13,7 @@ django.setup()
|
||||
import json
|
||||
from plogical.acl import ACLManager
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from websiteFunctions.models import Websites, ChildDomains, GitLogs, wpplugins, WPSites, WPStaging, WPSitesBackup
|
||||
from websiteFunctions.models import Websites, ChildDomains, GitLogs, wpplugins, WPSites, WPStaging, WPSitesBackup, RemoteBackupConfig,RemoteBackupSchedule, RemoteBackupsites
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
import subprocess
|
||||
import shlex
|
||||
@@ -202,6 +203,100 @@ class WebsiteManager:
|
||||
else:
|
||||
return redirect("https://cyberpanel.net/cyberpanel-addons")
|
||||
|
||||
|
||||
def RemoteBackupConfig(self, request=None, userID=None, DeleteID=None ):
|
||||
Data = {}
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
try:
|
||||
if DeleteID != None:
|
||||
BackupconfigDelete = RemoteBackupConfig.objects.get(pk=DeleteID)
|
||||
BackupconfigDelete.delete()
|
||||
except:
|
||||
pass
|
||||
|
||||
if ACLManager.CheckForPremFeature('wp-manager'):
|
||||
|
||||
Data['WPsites'] = ACLManager.GetALLWPObjects(currentACL, userID)
|
||||
allcon = RemoteBackupConfig.objects.all()
|
||||
Data['backupconfigs'] =[]
|
||||
for i in allcon:
|
||||
configr = json.loads(i.config)
|
||||
Data['backupconfigs'].append({
|
||||
'id':i.pk,
|
||||
'Type': i.configtype,
|
||||
'HostName': configr['Hostname'],
|
||||
'Path': configr['Path']
|
||||
})
|
||||
proc = httpProc(request, 'websiteFunctions/RemoteBackupConfig.html',
|
||||
Data, 'createWebsite')
|
||||
return proc.render()
|
||||
else:
|
||||
return redirect("https://cyberpanel.net/cyberpanel-addons")
|
||||
|
||||
|
||||
def BackupfileConfig(self, request=None, userID=None, RemoteConfigID=None, DeleteID=None ):
|
||||
Data = {}
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
Data['RemoteConfigID'] = RemoteConfigID
|
||||
RemoteConfigobj = RemoteBackupConfig.objects.get(pk=RemoteConfigID)
|
||||
try:
|
||||
if DeleteID != None:
|
||||
RemoteBackupConfigDelete = RemoteBackupSchedule.objects.get(pk=DeleteID)
|
||||
RemoteBackupConfigDelete.delete()
|
||||
except:
|
||||
pass
|
||||
|
||||
if ACLManager.CheckForPremFeature('wp-manager'):
|
||||
Data['WPsites'] = ACLManager.GetALLWPObjects(currentACL, userID)
|
||||
allsechedule = RemoteBackupSchedule.objects.filter(RemoteBackupConfig=RemoteConfigobj)
|
||||
Data['Backupschedule'] = []
|
||||
for i in allsechedule:
|
||||
Data['Backupschedule'].append({
|
||||
'id': i.pk,
|
||||
'Name': i.Name,
|
||||
'RemoteConfiguration': i.RemoteBackupConfig.configtype
|
||||
})
|
||||
proc = httpProc(request, 'websiteFunctions/BackupfileConfig.html',
|
||||
Data, 'createWebsite')
|
||||
return proc.render()
|
||||
else:
|
||||
return redirect("https://cyberpanel.net/cyberpanel-addons")
|
||||
|
||||
|
||||
def AddRemoteBackupsite(self, request=None, userID=None, RemoteScheduleID=None , DeleteSiteID=None):
|
||||
Data = {}
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
Data['RemoteScheduleID'] = RemoteScheduleID
|
||||
RemoteBackupScheduleobj= RemoteBackupSchedule.objects.get(pk=RemoteScheduleID)
|
||||
|
||||
try:
|
||||
if DeleteSiteID != None:
|
||||
RemoteBackupsitesDelete = RemoteBackupsites.objects.get(pk=DeleteSiteID)
|
||||
RemoteBackupsitesDelete.delete()
|
||||
except:
|
||||
pass
|
||||
|
||||
if ACLManager.CheckForPremFeature('wp-manager'):
|
||||
Data['WPsites'] = ACLManager.GetALLWPObjects(currentACL, userID)
|
||||
allRemoteBackupsites = RemoteBackupsites.objects.filter(owner=RemoteBackupScheduleobj)
|
||||
Data['RemoteBackupsites'] = []
|
||||
for i in allRemoteBackupsites:
|
||||
wpsite = WPSites.objects.get(pk=i.WPsites)
|
||||
Data['RemoteBackupsites'].append({
|
||||
'id': i.pk,
|
||||
'Title': wpsite.title,
|
||||
})
|
||||
proc = httpProc(request, 'websiteFunctions/AddRemoteBackupSite.html',
|
||||
Data, 'createWebsite')
|
||||
return proc.render()
|
||||
else:
|
||||
return redirect("https://cyberpanel.net/cyberpanel-addons")
|
||||
|
||||
def RestoreBackups(self, request=None, userID=None, DeleteID=None):
|
||||
Data = {}
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
@@ -1033,6 +1128,118 @@ class WebsiteManager:
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
|
||||
def SaveBackupConfig(self, userID=None, data=None):
|
||||
try:
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
ConfigType = data['type']
|
||||
if ConfigType == 'SFTP':
|
||||
Hname = data['Hname']
|
||||
Uname = data['Uname']
|
||||
Passwd = data['Passwd']
|
||||
path = data['path']
|
||||
config = {
|
||||
"Hostname": Hname,
|
||||
"Username": Uname,
|
||||
"Password": Passwd,
|
||||
"Path": path
|
||||
}
|
||||
mkobj = RemoteBackupConfig(owner=admin, configtype=ConfigType, config=json.dumps(config))
|
||||
mkobj.save()
|
||||
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
data_ret = {'status': 1, 'error_message': 'None',}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def SaveBackupSchedule(self, userID=None, data=None):
|
||||
try:
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
FileRetention = data['FileRetention']
|
||||
Backfrequency = data['Backfrequency']
|
||||
ScheduleName = data['ScheduleName']
|
||||
RemoteConfigID = data['RemoteConfigID']
|
||||
BackupType = data['BackupType']
|
||||
config = {
|
||||
'BackupType': BackupType
|
||||
}
|
||||
|
||||
RemoteBackupConfigobj = RemoteBackupConfig.objects.get(pk=RemoteConfigID)
|
||||
|
||||
svobj = RemoteBackupSchedule( RemoteBackupConfig=RemoteBackupConfigobj, Name=ScheduleName,
|
||||
timeintervel=Backfrequency, fileretention=FileRetention, config=json.dumps(config),
|
||||
lastrun=str(time.time()))
|
||||
svobj.save()
|
||||
|
||||
data_ret = {'status': 1, 'error_message': 'None',}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def AddWPsiteforRemoteBackup(self, userID=None, data=None):
|
||||
try:
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
WPid = data['WpsiteID']
|
||||
RemoteScheduleID = data['RemoteScheduleID']
|
||||
|
||||
wpsiteobj = WPSites.objects.get(pk=WPid)
|
||||
WPpath = wpsiteobj.path
|
||||
VHuser = wpsiteobj.owner.externalApp
|
||||
PhpVersion = wpsiteobj.owner.phpSelection
|
||||
php = PHPManager.getPHPString(PhpVersion)
|
||||
FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
|
||||
|
||||
####Get DB Name
|
||||
|
||||
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp config get DB_NAME --skip-plugins --skip-themes --path=%s' % (
|
||||
VHuser, FinalPHPPath, WPpath)
|
||||
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||
|
||||
if stdout.find('Error:') > -1:
|
||||
raise BaseException(stdout)
|
||||
else:
|
||||
Finaldbname = stdout.rstrip("\n")
|
||||
|
||||
## Get DB obj
|
||||
try:
|
||||
DBobj = Databases.objects.get(dbName=Finaldbname)
|
||||
except:
|
||||
raise BaseException(str("DataBase Not Found"))
|
||||
RemoteScheduleIDobj = RemoteBackupSchedule.objects.get(pk=RemoteScheduleID)
|
||||
|
||||
svobj = RemoteBackupsites( owner=RemoteScheduleIDobj, WPsites = WPid, database = DBobj.pk)
|
||||
svobj.save()
|
||||
|
||||
data_ret = {'status': 1, 'error_message': 'None',}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
|
||||
def installwpcore(self, userID=None, data=None):
|
||||
try:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user