Merge branch 'v2.0.1' into v2.0.2-dev

This commit is contained in:
Usman Nasir
2020-07-05 12:14:02 +05:00
3 changed files with 36 additions and 55 deletions

View File

@@ -23,10 +23,13 @@ elif echo $OUTPUT | grep -q "CentOS Linux 8" ; then
elif echo $OUTPUT | grep -q "Ubuntu 18.04" ; then
echo -e "\nDetecting Ubuntu 18.04...\n"
SERVER_OS="Ubuntu"
elif echo $OUTPUT | grep -q "Ubuntu 20.04" ; then
echo -e "\nDetecting Ubuntu 20.04...\n"
SERVER_OS="Ubuntu"
else
cat /etc/*release
echo -e "\nUnable to detect your OS...\n"
echo -e "\nCyberPanel is supported on Ubuntu 18.04, CentOS 7.x, CentOS 8.x and CloudLinux 7.x...\n"
echo -e "\nCyberPanel is supported on Ubuntu 18.04, Ubuntu 20.04, CentOS 7.x, CentOS 8.x and CloudLinux 7.x...\n"
exit 1
fi
}
@@ -141,9 +144,9 @@ if [[ $SERVER_COUNTRY == "CN" ]] ; then
GIT_CONTENT_URL="gitee.com/qtwrk/cyberpanel/raw"
fi
echo -e "CyberPanel Upgrade will start in 10 seconds"
echo -e "If you want to cancel, please press CTRL + C to cancel it"
sleep 10
#echo -e "CyberPanel Upgrade will start in 10 seconds"
#echo -e "If you want to cancel, please press CTRL + C to cancel it"
#sleep 10
echo -e "CyberPanel upgrading..."
rm -f /usr/local/cyberpanel_upgrade.sh
wget -O /usr/local/cyberpanel_upgrade.sh -q https://$GIT_CONTENT_URL/${BRANCH_NAME}/cyberpanel_upgrade.sh

View File

@@ -478,6 +478,8 @@ class backupUtilities:
## shutil.make_archive. Creating final package.
logging.CyberCPLogFileWriter.statusWriter(status, "Preparing final compressed package..\n")
make_archive(os.path.join(backupPath, backupName), 'gztar', tempStoragePath)
rmtree(tempStoragePath)
@@ -485,8 +487,6 @@ class backupUtilities:
backupObs = Backups.objects.filter(fileName=backupName)
## adding backup data to database.
filePath = '%s/%s.tar.gz' % (backupPath, backupName)
totalSize = '%sMB' % (str(int(os.path.getsize(filePath) / 1048576)))

View File

@@ -7,7 +7,8 @@ from plogical import backupUtilities as backupUtil
import subprocess
import shlex
from multiprocessing import Process
from shutil import move,rmtree
from plogical.backupSchedule import backupSchedule
from shutil import rmtree
class remoteBackup:
@@ -227,14 +228,13 @@ class remoteBackup:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]")
@staticmethod
def backupProcess(ipAddress, dir, backupLogPath,folderNumber,accountsToTransfer):
def backupProcess(ipAddress, dir, backupLogPath,folderNumber, accountsToTransfer):
try:
## dir is without forward slash
for virtualHost in accountsToTransfer:
try:
if virtualHost == "vmail" or virtualHost == "backup":
continue
@@ -243,59 +243,37 @@ class remoteBackup:
"%m.%d.%Y_%H-%M-%S") + "]" + " Currently generating local backups for: " + virtualHost + "\n")
writeToFile.close()
retValues = backupSchedule.createLocalBackup(virtualHost, backupLogPath)
finalData = json.dumps({'websiteToBeBacked': virtualHost})
r = requests.post("http://localhost:5003/backup/submitBackupCreation", data=finalData,verify=False)
data = json.loads(r.text)
fileName = data['tempStorage']+".tar.gz"
completePathToBackupFile = fileName
while (1):
time.sleep(2)
r = requests.post("http://localhost:5003/backup/backupStatus", data= finalData,verify=False)
data = json.loads(r.text)
if retValues[0] == 1:
writeToFile = open(backupLogPath, "a")
writeToFile.writelines("[" + time.strftime(
"%m.%d.%Y_%H-%M-%S") + "]" + " Waiting for backup to complete.. " + "\n")
"%m.%d.%Y_%H-%M-%S") + "]" + " Local Backup Completed for: " + virtualHost + "\n")
## move the generated backup file to specified destination
completedPathToSend = retValues[1] + ".tar.gz"
writeToFile.writelines("[" + time.strftime(
"%m.%d.%Y_%H-%M-%S") + "]" + " Sending " + completedPathToSend + " to " + ipAddress + ".\n")
remoteBackup.sendBackup(completedPathToSend, ipAddress, str(folderNumber), writeToFile)
writeToFile.writelines("[" + time.strftime(
"%m.%d.%Y_%H-%M-%S") + "]" + " Sent " + completedPathToSend + " to " + ipAddress + ".\n")
writeToFile.writelines("[" + time.strftime(
"%m.%d.%Y_%H-%M-%S") + "]" + " #############################################" + "\n")
writeToFile.close()
else:
writeToFile = open(backupLogPath, "a")
writeToFile.writelines("[" + time.strftime(
"%m.%d.%Y_%H-%M-%S") + "]" + 'Local backup failed for %s. Error message: %s' % (virtualHost, retValues[1]) )
writeToFile.close()
if data['abort'] == 1:
writeToFile = open(backupLogPath, "a")
writeToFile.writelines("[" + time.strftime(
"%m.%d.%Y_%H-%M-%S") + "]" + " Local Backup Completed for: " +virtualHost + " with status: "+ data['status'] +"\n")
## move the generated backup file to specified destination
if os.path.exists(completePathToBackupFile):
move(completePathToBackupFile,dir)
completedPathToSend = dir +"/" + completePathToBackupFile.split("/")[-1]
writeToFile.writelines("[" + time.strftime(
"%m.%d.%Y_%H-%M-%S") + "]" + " Sending " + completedPathToSend +" to "+ipAddress +".\n")
remoteBackup.sendBackup(completedPathToSend,ipAddress,str(folderNumber),writeToFile)
writeToFile.writelines("[" + time.strftime(
"%m.%d.%Y_%H-%M-%S") + "]" + " Sent " + completedPathToSend + " to " + ipAddress + ".\n")
writeToFile.writelines("[" + time.strftime(
"%m.%d.%Y_%H-%M-%S") + "]" + " #############################################" + "\n")
writeToFile.close()
break
except:
pass
@@ -306,7 +284,7 @@ class remoteBackup:
## removing local directory where backups were generated
time.sleep(5)
#rmtree(dir)
rmtree(dir)
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [backupProcess]")