From c17c59c422c630bab31f25e4844d8fd01af495de Mon Sep 17 00:00:00 2001 From: Abhishek Date: Mon, 22 Aug 2022 04:11:13 +0530 Subject: [PATCH 1/2] Fix for https://github.com/usmannasir/cyberpanel/issues/915 - Fresent LLC --- plogical/backupUtilities.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/plogical/backupUtilities.py b/plogical/backupUtilities.py index 55a51f2b0..a0a028b5d 100755 --- a/plogical/backupUtilities.py +++ b/plogical/backupUtilities.py @@ -369,11 +369,21 @@ def startBackup(tempStoragePath, backupName, backupPath, metaPath=None): from shutil import copytree + ## Get All Subfolders Under Domain name + allSubfoldersUnderDomain = [f.name for f in os.scandir(f'/home/{domainName}')] + #allSubfoldersUnderDomain = [f.name for f in os.scandir(f'/home/{domainName}') if f.is_dir()] + for subfolder in allSubfoldersUnderDomain: + if subfolder == 'logs' or subfolder == 'backup': + continue + command = f'cp -R /home/{domainName}/{subfolder} {tempStoragePath}/{subfolder}' + if ProcessUtilities.normalExecutioner(command) == 0: + raise BaseException(f'Failed to run cp command during backup generation.') + #copytree('/home/%s/public_html' % domainName, '%s/%s' % (tempStoragePath, 'public_html')) - command = f'cp -R /home/{domainName}/public_html {tempStoragePath}/public_html' + #command = f'cp -R /home/{domainName}/public_html {tempStoragePath}/public_html' - if ProcessUtilities.normalExecutioner(command) == 0: - raise BaseException(f'Failed to run cp command during backup generation.') + #if ProcessUtilities.normalExecutioner(command) == 0: + # raise BaseException(f'Failed to run cp command during backup generation.') # make_archive(os.path.join(tempStoragePath,"public_html"), 'gztar', os.path.join("/home",domainName,"public_html")) From 9e82397e6662f13bc25a33353a978fefa2c31614 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Fri, 2 Sep 2022 00:10:09 +0530 Subject: [PATCH 2/2] Ensure child domain's doc root is not not copied by default, instead let child domain docroot copy do the job in next step --- plogical/backupUtilities.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/plogical/backupUtilities.py b/plogical/backupUtilities.py index a0a028b5d..412195c6e 100755 --- a/plogical/backupUtilities.py +++ b/plogical/backupUtilities.py @@ -356,6 +356,9 @@ def startBackup(tempStoragePath, backupName, backupPath, metaPath=None): domainName = backupMetaData.find('masterDomain').text + ## Using childdomains to skip their docroot folder, we will copy them in another function + childDomains = backupMetaData.findall('ChildDomains/domain') + ## Saving original vhost conf file completPathToConf = f'{backupUtilities.Server_root}/conf/vhosts/{domainName}/vhost.conf' @@ -373,8 +376,19 @@ def startBackup(tempStoragePath, backupName, backupPath, metaPath=None): allSubfoldersUnderDomain = [f.name for f in os.scandir(f'/home/{domainName}')] #allSubfoldersUnderDomain = [f.name for f in os.scandir(f'/home/{domainName}') if f.is_dir()] for subfolder in allSubfoldersUnderDomain: - if subfolder == 'logs' or subfolder == 'backup': + isChildDomainRoot = False + try: + for childDomain in childDomains: + childPath = childDomain.find('path').text + if(childPath == f'/home/{domainName}/{subfolder}'): + isChildDomainRoot = True + break + except BaseException as msg: + pass + + if subfolder == 'logs' or subfolder == 'backup' or subfolder = '.ssh' or isChildDomainRoot: continue + command = f'cp -R /home/{domainName}/{subfolder} {tempStoragePath}/{subfolder}' if ProcessUtilities.normalExecutioner(command) == 0: raise BaseException(f'Failed to run cp command during backup generation.')