mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-12 00:06:09 +01:00
backuplistanddelete
This commit is contained in:
@@ -415,6 +415,9 @@
|
|||||||
<li><a href="{% url 'ConfigurePlugins' %}"
|
<li><a href="{% url 'ConfigurePlugins' %}"
|
||||||
title="{% trans 'ConfigurePlugins' %}"><span>{% trans "Configure Plugins" %}</span></a>
|
title="{% trans 'ConfigurePlugins' %}"><span>{% trans "Configure Plugins" %}</span></a>
|
||||||
</li>
|
</li>
|
||||||
|
<li><a href="{% url 'RestoreBackups' %}"
|
||||||
|
title="{% trans 'RestoreBackups' %}"><span>{% trans "Restore Backups" %}</span></a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</div><!-- .sidebar-submenu -->
|
</div><!-- .sidebar-submenu -->
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ django.setup()
|
|||||||
import threading as multi
|
import threading as multi
|
||||||
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
||||||
import subprocess
|
import subprocess
|
||||||
from websiteFunctions.models import ChildDomains, Websites, WPSites, WPStaging, wpplugins
|
from websiteFunctions.models import ChildDomains, Websites, WPSites, WPStaging, wpplugins, WPSitesBackup
|
||||||
from plogical import randomPassword
|
from plogical import randomPassword
|
||||||
from plogical.mysqlUtilities import mysqlUtilities
|
from plogical.mysqlUtilities import mysqlUtilities
|
||||||
from databases.models import Databases
|
from databases.models import Databases
|
||||||
@@ -2262,13 +2262,12 @@ $parameters = array(
|
|||||||
try:
|
try:
|
||||||
from managePHP.phpManager import PHPManager
|
from managePHP.phpManager import PHPManager
|
||||||
import json
|
import json
|
||||||
tempStatusPath = self.extraArgs['tempStatusPath']
|
logging.writeToFile("WPCreateBackup ....... start" )
|
||||||
self.tempStatusPath = tempStatusPath
|
self.tempStatusPath = self.extraArgs['tempStatusPath']
|
||||||
|
logging.statusWriter(self.tempStatusPath, 'Creating BackUp...,10')
|
||||||
|
|
||||||
statusFile = open(tempStatusPath, 'w')
|
|
||||||
statusFile.writelines('Creating BackUp...,10')
|
|
||||||
statusFile.close()
|
|
||||||
wpsite = WPSites.objects.get(pk=self.extraArgs['WPid'])
|
wpsite = WPSites.objects.get(pk=self.extraArgs['WPid'])
|
||||||
|
Adminobj = Administrator.objects.get(pk=self.extraArgs['adminID'])
|
||||||
|
|
||||||
website =Websites.objects.get(pk=wpsite.owner_id)
|
website =Websites.objects.get(pk=wpsite.owner_id)
|
||||||
PhpVersion = website.phpSelection
|
PhpVersion = website.phpSelection
|
||||||
@@ -2279,9 +2278,9 @@ $parameters = array(
|
|||||||
|
|
||||||
php = PHPManager.getPHPString(PhpVersion)
|
php = PHPManager.getPHPString(PhpVersion)
|
||||||
FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
|
FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
|
||||||
statusFile = open(tempStatusPath, 'w')
|
|
||||||
statusFile.writelines('Getting DataBase...,20')
|
|
||||||
statusFile.close()
|
logging.statusWriter(self.tempStatusPath, 'Getting DataBase...,20')
|
||||||
|
|
||||||
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp config get DB_NAME --skip-plugins --skip-themes --path=%s' % (VHuser, FinalPHPPath, WPsitepath)
|
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp config get DB_NAME --skip-plugins --skip-themes --path=%s' % (VHuser, FinalPHPPath, WPsitepath)
|
||||||
stdoutput = ProcessUtilities.outputExecutioner(command)
|
stdoutput = ProcessUtilities.outputExecutioner(command)
|
||||||
@@ -2308,9 +2307,7 @@ $parameters = array(
|
|||||||
ProcessUtilities.executioner(command)
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
### Make directory for backup
|
### Make directory for backup
|
||||||
statusFile = open(tempStatusPath, 'w')
|
logging.statusWriter(self.tempStatusPath, 'Creating Backup Directory...,40')
|
||||||
statusFile.writelines('Creating Backup Directory...,40')
|
|
||||||
statusFile.close()
|
|
||||||
|
|
||||||
command = "sudo -u %s mkdir -p %s/public_html" % (VHuser, tempPath)
|
command = "sudo -u %s mkdir -p %s/public_html" % (VHuser, tempPath)
|
||||||
ProcessUtilities.executioner(command)
|
ProcessUtilities.executioner(command)
|
||||||
@@ -2355,9 +2352,8 @@ $parameters = array(
|
|||||||
command = "rm -r /home/cyberpanel/config.json"
|
command = "rm -r /home/cyberpanel/config.json"
|
||||||
ProcessUtilities.executioner(command)
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
statusFile = open(tempStatusPath, 'w')
|
logging.statusWriter(self.tempStatusPath, 'Copying website data.....,50')
|
||||||
statusFile.writelines('Copying website data.....,50')
|
|
||||||
statusFile.close()
|
|
||||||
|
|
||||||
############## Copy Public_htnl to backup
|
############## Copy Public_htnl to backup
|
||||||
command = "sudo -u %s cp -R %s* %s/public_html" % (VHuser, WPsitepath, tempPath)
|
command = "sudo -u %s cp -R %s* %s/public_html" % (VHuser, WPsitepath, tempPath)
|
||||||
@@ -2372,9 +2368,9 @@ $parameters = array(
|
|||||||
if os.path.exists(ProcessUtilities.debugPath):
|
if os.path.exists(ProcessUtilities.debugPath):
|
||||||
logging.writeToFile(result)
|
logging.writeToFile(result)
|
||||||
|
|
||||||
statusFile = open(tempStatusPath, 'w')
|
logging.statusWriter(self.tempStatusPath, 'Copying DataBase.....,70')
|
||||||
statusFile.writelines('Copying DataBase.....,70')
|
|
||||||
statusFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
##### SQLDUMP database into new directory
|
##### SQLDUMP database into new directory
|
||||||
@@ -2385,10 +2381,10 @@ $parameters = array(
|
|||||||
if os.path.exists(ProcessUtilities.debugPath):
|
if os.path.exists(ProcessUtilities.debugPath):
|
||||||
logging.writeToFile(result)
|
logging.writeToFile(result)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
######## Zip backup directory
|
######## Zip backup directory
|
||||||
statusFile = open(tempStatusPath, 'w')
|
logging.statusWriter(self.tempStatusPath, 'Compressing backup files.....,80')
|
||||||
statusFile.writelines('Compressing backup files.....,90')
|
|
||||||
statusFile.close()
|
|
||||||
|
|
||||||
websitepath = "/home/%s"%websitedomain
|
websitepath = "/home/%s"%websitedomain
|
||||||
|
|
||||||
@@ -2396,26 +2392,26 @@ $parameters = array(
|
|||||||
command = "sudo -u %s tar -czvf %s -P %s" % (VHuser, FinalZipPath, tempPath)
|
command = "sudo -u %s tar -czvf %s -P %s" % (VHuser, FinalZipPath, tempPath)
|
||||||
result = ProcessUtilities.outputExecutioner(command)
|
result = ProcessUtilities.outputExecutioner(command)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
backupobj = WPSitesBackup(owner=Adminobj, WPSiteID=wpsite.id, WebsiteID=website.id, config=json_object)
|
||||||
|
backupobj.save()
|
||||||
if os.path.exists(ProcessUtilities.debugPath):
|
if os.path.exists(ProcessUtilities.debugPath):
|
||||||
logging.writeToFile(result)
|
logging.writeToFile(result)
|
||||||
|
|
||||||
|
|
||||||
command = f'rm -rf {tempPath}'
|
command = f'rm -rf {tempPath}'
|
||||||
ProcessUtilities.executioner(command)
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
statusFile = open(tempStatusPath, 'w')
|
|
||||||
statusFile.writelines("Successfully Created. [200]")
|
|
||||||
statusFile.close()
|
logging.statusWriter(self.tempStatusPath, 'Completed.[200]')
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
|
logging.writeToFile("Error WPCreateBackup ....... %s" % str(msg))
|
||||||
command = f'rm -rf {self.tempPath}'
|
command = f'rm -rf {self.tempPath}'
|
||||||
ProcessUtilities.executioner(command)
|
ProcessUtilities.executioner(command)
|
||||||
logging.writeToFile("Error WPCreateBackup ....... %s" % str(msg))
|
logging.statusWriter(self.tempStatusPath, str(msg))
|
||||||
statusFile = open(self.tempStatusPath, 'w')
|
|
||||||
statusFile.writelines(str(msg) + " [404]")
|
|
||||||
statusFile.close()
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1154,6 +1154,7 @@ app.controller('WPsiteHome', function ($scope, $http, $timeout, $compile, $windo
|
|||||||
$scope.couldNotConnect = true;
|
$scope.couldNotConnect = true;
|
||||||
$scope.goBackDisable = false;
|
$scope.goBackDisable = false;
|
||||||
|
|
||||||
|
|
||||||
$("#installProgress").css("width", "100%");
|
$("#installProgress").css("width", "100%");
|
||||||
$("#installProgressbackup").css("width", "100%");
|
$("#installProgressbackup").css("width", "100%");
|
||||||
$scope.installPercentage = "100";
|
$scope.installPercentage = "100";
|
||||||
|
|||||||
179
websiteFunctions/templates/websiteFunctions/RestoreBackups.html
Normal file
179
websiteFunctions/templates/websiteFunctions/RestoreBackups.html
Normal file
@@ -0,0 +1,179 @@
|
|||||||
|
{% extends "baseTemplate/index.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
{% block title %}{% trans "Restore Backpus - CyberPanel" %}{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
{% load static %}
|
||||||
|
{% get_current_language as LANGUAGE_CODE %}
|
||||||
|
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready(function () {
|
||||||
|
$('[data-toggle="tooltip"]').tooltip();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
table { /* tables still need 'cellspacing="0"' in the markup */
|
||||||
|
border-collapse: separate;
|
||||||
|
border-spacing: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-spacing {
|
||||||
|
border-spacing: 0em .9em;
|
||||||
|
}
|
||||||
|
|
||||||
|
table th:nth-child(1) {
|
||||||
|
|
||||||
|
/* Safari 3-4, iOS 1-3.2, Android 1.6- */
|
||||||
|
-webkit-border-radius: 3px 0px 0px 3px;
|
||||||
|
|
||||||
|
/* Firefox 1-3.6 */
|
||||||
|
-moz-border-radius: 3px 0px 0px 3px;
|
||||||
|
|
||||||
|
/* Opera 10.5, IE 9, Safari 5, Chrome, Firefox 4, iOS 4, Android 2.1+ */
|
||||||
|
border-radius: 3px 0px 0px 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table th:nth-child(1) {
|
||||||
|
|
||||||
|
/* Safari 3-4, iOS 1-3.2, Android 1.6- */
|
||||||
|
-webkit-border-radius: 20px 0px 0px 20px;
|
||||||
|
|
||||||
|
/* Firefox 1-3.6 */
|
||||||
|
-moz-border-radius: 20px 0px 0px 20px;
|
||||||
|
|
||||||
|
/* Opera 10.5, IE 9, Safari 5, Chrome, Firefox 4, iOS 4, Android 2.1+ */
|
||||||
|
border-radius: 20px 0px 0px 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table th:nth-last-child(1) {
|
||||||
|
/* Safari 3-4, iOS 1-3.2, Android 1.6- */
|
||||||
|
-webkit-border-radius: 0px 20px 20px 0px;
|
||||||
|
|
||||||
|
/* Firefox 1-3.6 */
|
||||||
|
-moz-border-radius: 0px 20px 20px 0px;
|
||||||
|
|
||||||
|
/* Opera 10.5, IE 9, Safari 5, Chrome, Firefox 4, iOS 4, Android 2.1+ */
|
||||||
|
border-radius: 0px 20px 20px 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table td:nth-child(1) {
|
||||||
|
|
||||||
|
/* Safari 3-4, iOS 1-3.2, Android 1.6- */
|
||||||
|
-webkit-border-radius: 20px 0px 0px 20px;
|
||||||
|
|
||||||
|
/* Firefox 1-3.6 */
|
||||||
|
-moz-border-radius: 20px 0px 0px 20px;
|
||||||
|
|
||||||
|
/* Opera 10.5, IE 9, Safari 5, Chrome, Firefox 4, iOS 4, Android 2.1+ */
|
||||||
|
border-radius: 20px 0px 0px 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table td:nth-last-child(1) {
|
||||||
|
/* Safari 3-4, iOS 1-3.2, Android 1.6- */
|
||||||
|
-webkit-border-radius: 0px 20px 20px 0px;
|
||||||
|
|
||||||
|
/* Firefox 1-3.6 */
|
||||||
|
-moz-border-radius: 0px 20px 20px 0px;
|
||||||
|
|
||||||
|
/* Opera 10.5, IE 9, Safari 5, Chrome, Firefox 4, iOS 4, Android 2.1+ */
|
||||||
|
border-radius: 0px 20px 20px 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
<div ng-controller="listWebsites" class="container">
|
||||||
|
|
||||||
|
<div id="page-title">
|
||||||
|
<h2 id="domainNamePage">{% trans "List Backups " %}
|
||||||
|
</h2>
|
||||||
|
<img ng-hide="cyberPanelLoading" src="{% static 'images/loading.gif' %}">
|
||||||
|
<p>{% trans "On this page you can Restore, list, modify and delete Backups Wordpress Sites from your server." %}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<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;">Website
|
||||||
|
</th>
|
||||||
|
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Action
|
||||||
|
</th>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody style="background-color: #d9eefa">
|
||||||
|
{% for sub in job %}
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td style="padding: 13px;">
|
||||||
|
<a href="#">
|
||||||
|
<p style="font-weight: bold; text-transform: uppercase; ">{{ sub.id }}</p>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td style="padding: 13px;">
|
||||||
|
{{ sub.title }}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td style="padding: 13px;">
|
||||||
|
|
||||||
|
<button
|
||||||
|
data-toggle="modal"
|
||||||
|
data-target="#DeleteMember" aria-label=""
|
||||||
|
onclick="DeleteWPNow('{% url 'RestoreBackups' %}?DeleteID={{ sub.id }}')"
|
||||||
|
type="button" class="btn btn-border btn-alt border-red btn-link font-red">
|
||||||
|
Delete
|
||||||
|
</button>
|
||||||
|
<div id="DeleteMember" class="modal fade" role="dialog">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<!-- Modal content-->
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal">×
|
||||||
|
</button>
|
||||||
|
<h4 class="modal-title">Delete WordPress Site
|
||||||
|
<img ng-hide="$parent.cyberPanelLoading"
|
||||||
|
src="/static/images/loading.gif"
|
||||||
|
style="display: none;">
|
||||||
|
</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<form name="DeleteDocumentRootForm" action="/"
|
||||||
|
class="form-horizontal">
|
||||||
|
|
||||||
|
<span>Do you want to delete the site?</span>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-primary"
|
||||||
|
onclick="FinalDeleteWPNow()">Yes
|
||||||
|
</button>
|
||||||
|
<button type="button" ng-disabled="savingSettings"
|
||||||
|
class="btn btn-default" data-dismiss="modal">
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
|
||||||
|
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -20,6 +20,7 @@ urlpatterns = [
|
|||||||
url(r'^createWordpress$', views.WPCreate, name='createWordpress'),
|
url(r'^createWordpress$', views.WPCreate, name='createWordpress'),
|
||||||
url(r'^ListWPSites$', views.ListWPSites, name='ListWPSites'),
|
url(r'^ListWPSites$', views.ListWPSites, name='ListWPSites'),
|
||||||
url(r'^WPHome$', views.WPHome, name='WPHome'),
|
url(r'^WPHome$', views.WPHome, name='WPHome'),
|
||||||
|
url(r'^RestoreBackups$', views.RestoreBackups, name='RestoreBackups'),
|
||||||
url(r'^AutoLogin$', views.AutoLogin, name='AutoLogin'),
|
url(r'^AutoLogin$', views.AutoLogin, name='AutoLogin'),
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,15 @@ def WPHome(request):
|
|||||||
return wm.WPHome(request, userID, WPid, DeleteID)
|
return wm.WPHome(request, userID, WPid, DeleteID)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
def RestoreBackups(request):
|
||||||
|
try:
|
||||||
|
userID = request.session['userID']
|
||||||
|
|
||||||
|
DeleteID = request.GET.get('DeleteID')
|
||||||
|
wm = WebsiteManager()
|
||||||
|
return wm.RestoreBackups(request, userID, DeleteID)
|
||||||
|
except KeyError:
|
||||||
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
def AutoLogin(request):
|
def AutoLogin(request):
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ django.setup()
|
|||||||
import json
|
import json
|
||||||
from plogical.acl import ACLManager
|
from plogical.acl import ACLManager
|
||||||
import plogical.CyberCPLogFileWriter as logging
|
import plogical.CyberCPLogFileWriter as logging
|
||||||
from websiteFunctions.models import Websites, ChildDomains, GitLogs, wpplugins, WPSites, WPStaging
|
from websiteFunctions.models import Websites, ChildDomains, GitLogs, wpplugins, WPSites, WPStaging, WPSitesBackup
|
||||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||||
import subprocess
|
import subprocess
|
||||||
import shlex
|
import shlex
|
||||||
@@ -142,6 +142,45 @@ class WebsiteManager:
|
|||||||
Data, 'createWebsite')
|
Data, 'createWebsite')
|
||||||
return proc.render()
|
return proc.render()
|
||||||
|
|
||||||
|
def RestoreBackups(self, request=None, userID=None, DeleteID=None):
|
||||||
|
Data = {}
|
||||||
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
|
admin = Administrator.objects.get(pk=userID)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
backobj = WPSitesBackup.objects.filter(owner=admin)
|
||||||
|
|
||||||
|
try:
|
||||||
|
if DeleteID != None:
|
||||||
|
DeleteIDobj = WPSitesBackup.objects.get(pk=DeleteID)
|
||||||
|
DeleteIDobj.delete()
|
||||||
|
|
||||||
|
except BaseException as msg:
|
||||||
|
pass
|
||||||
|
Data['job'] = []
|
||||||
|
|
||||||
|
for sub in backobj:
|
||||||
|
try:
|
||||||
|
wpsite = WPSites.objects.get(pk=sub.WPSiteID)
|
||||||
|
web = wpsite.title
|
||||||
|
except:
|
||||||
|
web = "Website Not Found"
|
||||||
|
|
||||||
|
Data['job'].append({
|
||||||
|
'id': sub.id,
|
||||||
|
'title': web,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
proc = httpProc(request, 'websiteFunctions/RestoreBackups.html',
|
||||||
|
Data, 'createWebsite')
|
||||||
|
return proc.render()
|
||||||
|
|
||||||
def AutoLogin(self, request=None, userID=None):
|
def AutoLogin(self, request=None, userID=None):
|
||||||
|
|
||||||
WPid = request.GET.get('id')
|
WPid = request.GET.get('id')
|
||||||
|
|||||||
Reference in New Issue
Block a user