Skip to content
Permalink
Browse files
bug fix: to restore folders
  • Loading branch information
usmannasir committed Apr 6, 2020
1 parent 56fb493 commit c2a54f09906edc7a80b8e1fe2dd9ff9e08a72fbe
Showing 1 changed file with 18 additions and 17 deletions.
@@ -28,7 +28,8 @@
from xml.etree import ElementTree
from xml.dom import minidom
import time
from shutil import copy, copytree
from shutil import copy
from distutils.dir_util import copy_tree
from random import randint
from plogical.processUtilities import ProcessUtilities
try:
@@ -42,7 +43,7 @@
pass

VERSION = '2.0'
BUILD = '1'
BUILD = 1

## I am not the monster that you think I am..

@@ -365,7 +366,8 @@ def startBackup(tempStoragePath, backupName, backupPath, metaPath = None):

## Stop making archive of document_root and copy instead

copytree('/home/%s/public_html' % domainName, tempStoragePath)

copy_tree('/home/%s/public_html' % domainName, '%s/%s' % (tempStoragePath, 'public_html'))

#make_archive(os.path.join(tempStoragePath,"public_html"), 'gztar', os.path.join("/home",domainName,"public_html"))

@@ -451,7 +453,7 @@ def BackupRoot(tempStoragePath, backupName, backupPath, metaPath=None):
pass

if childPath.find('/home/%s/public_html' % domainName) == -1:
copytree(childPath, '%s/%s-docroot' % (tempStoragePath, actualChildDomain))
copy_tree(childPath, '%s/%s-docroot' % (tempStoragePath, actualChildDomain))

except BaseException as msg:
pass
@@ -649,8 +651,6 @@ def startRestore(backupName, dir):
completPath = "/home/backup/transfer-"+str(dir)+"/"+backupFileName ## without extension
originalFile = "/home/backup/transfer-"+str(dir)+"/"+backupName ## with extension



pathToCompressedHome = os.path.join(completPath,"public_html.tar.gz")

if not os.path.exists(completPath):
@@ -671,7 +671,6 @@ def startRestore(backupName, dir):
tar.extractall(completPath)
tar.close()


logging.CyberCPLogFileWriter.statusWriter(status, "Creating Accounts,Databases and DNS records!")

########### Creating website and its dabases
@@ -680,12 +679,14 @@ def startRestore(backupName, dir):
backupMetaData = ElementTree.parse(os.path.join(completPath, "meta.xml"))
masterDomain = backupMetaData.find('masterDomain').text


twoPointO = 0
try:
version = backupMetaData.find('VERSION').text
build = backupMetaData.find('BUILD').text
twoPointO = 1
except:
version = '2.0'
build = '0'
twoPointO = 0

result = backupUtilities.createWebsiteFromBackup(backupName, dir)

@@ -713,8 +714,6 @@ def startRestore(backupName, dir):
logging.CyberCPLogFileWriter.statusWriter(status, "Error Message: " + result[1] + ". Not able to create Account, Databases and DNS Records, aborting. [575][5009]")
return 0

if float(version) > 2.0 or float(build) > 0:
copytree('%s/public_html' % (completPath), '/home/%s' % masterDomain)

########### Creating child/sub/addon/parked domains

@@ -783,14 +782,13 @@ def startRestore(backupName, dir):

if float(version) > 2.0 or float(build) > 0:
if path.find('/home/%s/public_html' % masterDomain) == -1:
copytree('%s/%s-docroot' % (completPath, domain), path)
copy_tree('%s/%s-docroot' % (completPath, domain), path)

continue
else:
logging.CyberCPLogFileWriter.writeToFile('Error domain %s' % (domain))
logging.CyberCPLogFileWriter.statusWriter(status, "Error Message: " + retValues[1] + ". Not able to create child domains, aborting. [635][5009]")
return 0

except BaseException as msg:
status = open(os.path.join(completPath,'status'), "w")
status.write("Error Message: " + str(msg) +". Not able to create child domains, aborting. [638][5009]")
@@ -823,7 +821,6 @@ def startRestore(backupName, dir):
result = mailUtilities.createEmailAccount(masterDomain, username, password, 'restore')
if result[0] == 0:
raise BaseException(result[1])

except BaseException as msg:
logging.CyberCPLogFileWriter.statusWriter(status, "Error Message: " + str(msg) +". Not able to create email accounts, aborting. [671][5009]")
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startRestore]")
@@ -850,9 +847,13 @@ def startRestore(backupName, dir):
# /home/backup/backup-example.com-02.13.2018_10-24-52/public_html.tar.gz
## Moving above v2.0.0 extracting webhome data is not required, thus commenting below lines

# tar = tarfile.open(pathToCompressedHome)
# tar.extractall(websiteHome)
# tar.close()
if not twoPointO:
tar = tarfile.open(pathToCompressedHome)
tar.extractall(websiteHome)
tar.close()
else:
if float(version) > 2.0 or float(build) > 0:
copy_tree('%s/public_html' % (completPath), websiteHome)

## extracting email accounts

0 comments on commit c2a54f0

Please sign in to comment.