backupexpot

This commit is contained in:
Hassan Hashmi
2022-08-15 12:31:38 +05:00
parent 1d94a8e1d7
commit 9a8f8a9182
3 changed files with 59 additions and 22 deletions

View File

@@ -114,7 +114,6 @@
<style> <style>
{{ cosmetic.MainDashboardCSS | safe }} {{ cosmetic.MainDashboardCSS | safe }}
</style> </style>
</head> </head>

View File

@@ -2409,7 +2409,10 @@ $parameters = array(
logging.writeToFile(f'DB Name Dump: {DataBaseName}') logging.writeToFile(f'DB Name Dump: {DataBaseName}')
##### SQLDUMP database into new directory ##### SQLDUMP database into new directory
command = "mysqldump %s --result-file %s/%s.sql" % (DataBaseName, self.tempPath, DataBaseName) # command = "mysqldump %s --result-file %s/%s.sql" % (DataBaseName, self.tempPath, DataBaseName)
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp --allow-root --skip-plugins --skip-themes --path=%s db export %s/%s.sql' % (
VHuser, FinalPHPPath, WPsitepath, self.tempPath, DataBaseName)
if os.path.exists(ProcessUtilities.debugPath): if os.path.exists(ProcessUtilities.debugPath):
logging.writeToFile(command) logging.writeToFile(command)
@@ -2683,7 +2686,9 @@ $parameters = array(
##### SQLDUMP database into new directory ##### SQLDUMP database into new directory
command = "mysqldump %s --result-file %s/%s.sql" % (DataBaseName, self.tempPath, DataBaseName) # command = "mysqldump %s --result-file %s/%s.sql" % (DataBaseName, self.tempPath, DataBaseName)
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp --allow-root --skip-plugins --skip-themes --path=%s db export %s/%s.sql' % (
VHuser, FinalPHPPath, WPsitepath, self.tempPath, DataBaseName)
if os.path.exists(ProcessUtilities.debugPath): if os.path.exists(ProcessUtilities.debugPath):
logging.writeToFile(command) logging.writeToFile(command)
@@ -2883,7 +2888,9 @@ $parameters = array(
# dump Mysql file in unzippath path # dump Mysql file in unzippath path
unzippathdb = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % (self.tempPath, oldtemppath, DumpFileName) unzippathdb = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % (self.tempPath, oldtemppath, DumpFileName)
command = "mysql -u root %s < %s" % (Finaldbname, unzippathdb) # command = "mysql -u root %s < %s" % (Finaldbname, unzippathdb)
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp --allow-root --skip-plugins --skip-themes --path=%s --quiet db import %s' % (
VHuser, FinalPHPPath, newWPpath, unzippathdb)
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1) result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
if result == 0: if result == 0:
@@ -3411,7 +3418,9 @@ $parameters = array(
# dump Mysql file in unzippath path # dump Mysql file in unzippath path
unzippath2 = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % ( unzippath2 = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % (
self.tempPath, oldtemppath, DumpFileName) self.tempPath, oldtemppath, DumpFileName)
command = "mysql -u root %s < %s" % (Finaldbname, unzippath2) # command = "mysql -u root %s < %s" % (Finaldbname, unzippath2)
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp --allow-root --skip-plugins --skip-themes --path=%s --quiet db import %s' % (
VHuser, FinalPHPPath, newWPpath, unzippath2)
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1) result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
if result == 0: if result == 0:
@@ -3571,7 +3580,9 @@ $parameters = array(
# dump Mysql file in unzippath path # dump Mysql file in unzippath path
unzippath2 = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % ( unzippath2 = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % (
self.tempPath, oldtemppath, DumpFileName) self.tempPath, oldtemppath, DumpFileName)
command = "mysql -u root %s < %s" % (Finaldbname, unzippath2) # command = "mysql -u root %s < %s" % (Finaldbname, unzippath2)
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp --allow-root --skip-plugins --skip-themes --path=%s --quiet db import %s' % (
VHuser, FinalPHPPath, newWPpath, unzippath2)
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1) result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
if result == 0: if result == 0:
@@ -3790,7 +3801,9 @@ $parameters = array(
# dump Mysql file in unzippath path # dump Mysql file in unzippath path
unzippath2 = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % (self.tempPath, oldtemppath, DumpFileName) unzippath2 = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % (self.tempPath, oldtemppath, DumpFileName)
command = "mysql -u root %s < %s" % (Finaldbname, unzippath2) # command = "mysql -u root %s < %s" % (Finaldbname, unzippath2)
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp --allow-root --skip-plugins --skip-themes --path=%s --quiet db import %s' % (
VHuser, FinalPHPPath, newWPpath, unzippath2)
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1) result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
if stdout.find('Error:') > -1: if stdout.find('Error:') > -1:
@@ -3977,7 +3990,9 @@ $parameters = array(
# dump Mysql file in unzippath path # dump Mysql file in unzippath path
unzippathdb = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % (self.tempPath, oldtemppath, DumpFileName) unzippathdb = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % (self.tempPath, oldtemppath, DumpFileName)
command = "mysql -u root %s < %s" % (Finaldbname, unzippathdb) # command = "mysql -u root %s < %s" % (Finaldbname, unzippathdb)
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp --allow-root --skip-plugins --skip-themes --path=%s --quiet db import %s' % (
VHuser, FinalPHPPath, newWPpath, unzippathdb)
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1) result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
if result == 0: if result == 0:
@@ -4500,7 +4515,9 @@ $parameters = array(
# dump Mysql file in unzippath path # dump Mysql file in unzippath path
unzippath2 = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % ( unzippath2 = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % (
self.tempPath, oldtemppath, DumpFileName) self.tempPath, oldtemppath, DumpFileName)
command = "mysql -u root %s < %s" % (Finaldbname, unzippath2) # command = "mysql -u root %s < %s" % (Finaldbname, unzippath2)
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp --allow-root --skip-plugins --skip-themes --path=%s --quiet db import %s' % (
VHuser, FinalPHPPath, newWPpath, unzippath2)
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1) result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
if result == 0: if result == 0:
@@ -4660,7 +4677,9 @@ $parameters = array(
# dump Mysql file in unzippath path # dump Mysql file in unzippath path
unzippath2 = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % ( unzippath2 = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % (
self.tempPath, oldtemppath, DumpFileName) self.tempPath, oldtemppath, DumpFileName)
command = "mysql -u root %s < %s" % (Finaldbname, unzippath2) # command = "mysql -u root %s < %s" % (Finaldbname, unzippath2)
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp --allow-root --skip-plugins --skip-themes --path=%s --quiet db import %s' % (
VHuser, FinalPHPPath, newWPpath, unzippath2)
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1) result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
if result == 0: if result == 0:
@@ -4880,7 +4899,9 @@ $parameters = array(
# dump Mysql file in unzippath path # dump Mysql file in unzippath path
unzippath2 = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % (self.tempPath, oldtemppath, DumpFileName) unzippath2 = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % (self.tempPath, oldtemppath, DumpFileName)
command = "mysql -u root %s < %s" % (Finaldbname, unzippath2) # command = "mysql -u root %s < %s" % (Finaldbname, unzippath2)
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp --allow-root --skip-plugins --skip-themes --path=%s --quiet db import %s' % (
VHuser, FinalPHPPath, newWPpath, unzippath2)
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1) result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
if stdout.find('Error:') > -1: if stdout.find('Error:') > -1:
@@ -4942,7 +4963,6 @@ $parameters = array(
from plogical.installUtilities import installUtilities from plogical.installUtilities import installUtilities
installUtilities.reStartLiteSpeed() installUtilities.reStartLiteSpeed()
#####Local BAckups #####Local BAckups
else: else:
##### CHeck if Backup type is Only Database ##### CHeck if Backup type is Only Database
@@ -5031,7 +5051,10 @@ $parameters = array(
# dump Mysql file in unzippath path # dump Mysql file in unzippath path
unzippathdb = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % (self.tempPath, oldtemppath, DumpFileName) unzippathdb = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % (self.tempPath, oldtemppath, DumpFileName)
command = "mysql -u root %s < %s" % (Finaldbname, unzippathdb) # command = "mysql -u root %s < %s" % (Finaldbname, unzippathdb)
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp --allow-root --skip-plugins --skip-themes --path=%s --quiet db import %s' % (
VHuser, FinalPHPPath, newWPpath, unzippathdb)
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1) result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
if result == 0: if result == 0:
@@ -5559,7 +5582,9 @@ $parameters = array(
# dump Mysql file in unzippath path # dump Mysql file in unzippath path
unzippath2 = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % ( unzippath2 = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % (
self.tempPath, oldtemppath, DumpFileName) self.tempPath, oldtemppath, DumpFileName)
command = "mysql -u root %s < %s" % (Finaldbname, unzippath2) # command = "mysql -u root %s < %s" % (Finaldbname, unzippath2)
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp --allow-root --skip-plugins --skip-themes --path=%s --quiet db import %s' % (
VHuser, FinalPHPPath, newWPpath, unzippath2)
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1) result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
if result == 0: if result == 0:
@@ -5719,7 +5744,9 @@ $parameters = array(
# dump Mysql file in unzippath path # dump Mysql file in unzippath path
unzippath2 = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % ( unzippath2 = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % (
self.tempPath, oldtemppath, DumpFileName) self.tempPath, oldtemppath, DumpFileName)
command = "mysql -u root %s < %s" % (Finaldbname, unzippath2) # command = "mysql -u root %s < %s" % (Finaldbname, unzippath2)
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp --allow-root --skip-plugins --skip-themes --path=%s --quiet db import %s' % (
VHuser, FinalPHPPath, newWPpath, unzippath2)
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1) result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
if result == 0: if result == 0:
@@ -5937,12 +5964,18 @@ $parameters = array(
# dump Mysql file in unzippath path # dump Mysql file in unzippath path
unzippath2 = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % (self.tempPath, oldtemppath, DumpFileName) unzippath2 = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % (self.tempPath, oldtemppath, DumpFileName)
command = "mysql -u root %s < %s" % (Finaldbname, unzippath2) # command = "mysql -u root %s < %s" % (Finaldbname, unzippath2)
command = 'sudo -u %s %s /usr/bin/wp --allow-root --skip-plugins --skip-themes --path=%s --quiet db import %s' % (
VHuser, FinalPHPPath, newWPpath, unzippath2)
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1) result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
logging.writeToFile("stdoutput.....-->"+str(stdout))
logging.writeToFile("result:.....-->"+str(stdout))
if stdout.find('Error:') > -1: if stdout.find('Error:') > -1:
raise BaseException(stdout) raise BaseException(stdout)
logging.statusWriter(self.tempStatusPath, 'Restoreing Data Base...,80') logging.statusWriter(self.tempStatusPath, 'Restoreing Data Base...,80')
#####SetUp DataBase Settings #####SetUp DataBase Settings
##set DBName ##set DBName
@@ -5989,12 +6022,12 @@ $parameters = array(
ProcessUtilities.outputExecutioner(command, None, None, None, 1) ProcessUtilities.outputExecutioner(command, None, None, None, 1)
##Remove temppath # ##Remove temppath
command = f'rm -rf {self.tempPath}' # command = f'rm -rf {self.tempPath}'
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1) # result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
#
if stdout.find('Error:') > -1: # if stdout.find('Error:') > -1:
raise BaseException(stdout) # raise BaseException(stdout)
###Restart Server ###Restart Server

View File

@@ -1,4 +1,5 @@
#!/usr/local/CyberCP/bin/python #!/usr/local/CyberCP/bin/python
import html
import os import os
import os.path import os.path
import sys import sys
@@ -740,6 +741,7 @@ class WebsiteManager:
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp core version --skip-plugins --skip-themes --path=%s' % (Vhuser, FinalPHPPath, path) command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp core version --skip-plugins --skip-themes --path=%s' % (Vhuser, FinalPHPPath, path)
version = ProcessUtilities.outputExecutioner(command) version = ProcessUtilities.outputExecutioner(command)
version = html.escape(version)
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp plugin status litespeed-cache --skip-plugins --skip-themes --path=%s' % (Vhuser, FinalPHPPath, path) command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp plugin status litespeed-cache --skip-plugins --skip-themes --path=%s' % (Vhuser, FinalPHPPath, path)
@@ -945,6 +947,7 @@ class WebsiteManager:
if stdoutput.find('Error:') == -1: if stdoutput.find('Error:') == -1:
DataBaseName = stdoutput.rstrip("\n") DataBaseName = stdoutput.rstrip("\n")
DataBaseName = html.escape(DataBaseName)
else: else:
data_ret = {'status': 0, 'error_message': stdoutput} data_ret = {'status': 0, 'error_message': stdoutput}
json_data = json.dumps(data_ret) json_data = json.dumps(data_ret)
@@ -955,6 +958,7 @@ class WebsiteManager:
if stdoutput.find('Error:') == -1: if stdoutput.find('Error:') == -1:
DataBaseUser = stdoutput.rstrip("\n") DataBaseUser = stdoutput.rstrip("\n")
DataBaseUser = html.escape(DataBaseUser)
else: else:
data_ret = {'status': 0, 'error_message': stdoutput} data_ret = {'status': 0, 'error_message': stdoutput}
json_data = json.dumps(data_ret) json_data = json.dumps(data_ret)
@@ -965,6 +969,7 @@ class WebsiteManager:
if stdoutput.find('Error:') == -1: if stdoutput.find('Error:') == -1:
tableprefix = stdoutput.rstrip("\n") tableprefix = stdoutput.rstrip("\n")
tableprefix = html.escape(tableprefix)
else: else:
data_ret = {'status': 0, 'error_message': stdoutput} data_ret = {'status': 0, 'error_message': stdoutput}
json_data = json.dumps(data_ret) json_data = json.dumps(data_ret)