@@ -98,6 +98,11 @@ def prepareBackupMeta(backupDomain, backupName, tempStoragePath, backupPath, Fro
9898 child = SubElement (metaFileXML , 'BUILD' )
9999 child .text = str (BUILD )
100100
101+ ### try to take care of - https://github.com/usmannasir/cyberpanel/issues/1196
102+
103+ child = SubElement (metaFileXML , 'BackupWholeDir' )
104+ child .text = str (1 )
105+
101106 child = SubElement (metaFileXML , 'masterDomain' )
102107 child .text = backupDomain
103108
@@ -370,7 +375,9 @@ def startBackup(tempStoragePath, backupName, backupPath, metaPath=None):
370375 from shutil import copytree
371376
372377 #copytree('/home/%s/public_html' % domainName, '%s/%s' % (tempStoragePath, 'public_html'))
373- command = f'cp -R /home/{ domainName } /public_html { tempStoragePath } /public_html'
378+ #command = f'cp -R /home/{domainName}/public_html {tempStoragePath}/public_html'
379+ ### doing backup of whole dir and keeping it in public_html folder will restore from here - ref https://github.com/usmannasir/cyberpanel/issues/1196
380+ command = f"rsync -av --exclude=.wp-cli --exclude=logs --exclude=backup --exclude=lscache /home/{ domainName } / { tempStoragePath } /public_html/"
374381
375382 if ProcessUtilities .normalExecutioner (command ) == 0 :
376383 raise BaseException (f'Failed to run cp command during backup generation.' )
@@ -498,12 +505,12 @@ def BackupRoot(tempStoragePath, backupName, backupPath, metaPath=None, externalA
498505 #make_archive(os.path.join(tempStoragePath, "sslData-" + domainName), 'gztar', sslStoragePath)
499506 except :
500507 pass
508+ ## no need to do this as on line 380 whole dir will be backuped up
501509
502- if childPath .find (f'/home/{ domainName } /public_html' ) == - 1 :
503- # copy_tree(childPath, '%s/%s-docroot' % (tempStoragePath, actualChildDomain))
504- command = f'cp -R { childPath } { tempStoragePath } /{ actualChildDomain } -docroot'
505- ProcessUtilities .executioner (command , externalApp )
506-
510+ # if childPath.find(f'/home/{domainName}/public_html') == -1:
511+ # # copy_tree(childPath, '%s/%s-docroot' % (tempStoragePath, actualChildDomain))
512+ # command = f'cp -R {childPath} {tempStoragePath}/{actualChildDomain}-docroot'
513+ # ProcessUtilities.executioner(command, externalApp)
507514 except BaseException as msg :
508515 pass
509516
@@ -807,9 +814,11 @@ def startRestore(backupName, dir):
807814 try :
808815 version = backupMetaData .find ('VERSION' ).text
809816 build = backupMetaData .find ('BUILD' ).text
817+ BackupWholeDir = int (backupMetaData .find ('BackupWholeDir' ).text )
810818 twoPointO = 1
811819 except :
812820 twoPointO = 0
821+ BackupWholeDir = 0
813822
814823 result = backupUtilities .createWebsiteFromBackup (backupName , dir )
815824
@@ -917,17 +926,19 @@ def startRestore(backupName, dir):
917926 if float (version ) > 2.0 or float (build ) > 0 :
918927 if path .find ('/home/%s/public_html' % masterDomain ) == - 1 :
919928
920- #copy_tree('%s/%s-docroot' % (completPath, domain), path)
929+ if BackupWholeDir == 0 :
921930
922- ## First remove if already exists
931+ #copy_tree('%s/%s-docroot' % (completPath, domain), path)
923932
924- command = 'rm -rf %s' % (path )
925- ProcessUtilities .executioner (command )
933+ ## First remove if already exists
926934
927- ##
935+ command = 'rm -rf %s' % (path )
936+ ProcessUtilities .executioner (command )
928937
929- command = 'cp -R %s/%s-docroot %s' % (completPath , domain , path )
930- ProcessUtilities .executioner (command )
938+ ##
939+
940+ command = 'cp -R %s/%s-docroot %s' % (completPath , domain , path )
941+ ProcessUtilities .executioner (command )
931942
932943 continue
933944 else :
@@ -1053,8 +1064,11 @@ def startRestore(backupName, dir):
10531064 ProcessUtilities .executioner (command )
10541065
10551066 ##
1056-
1057- command = 'cp -R %s/public_html %s' % (completPath , websiteHome )
1067+ if BackupWholeDir :
1068+ #command = 'cp -R %s/public_html/* %s/*' % (completPath, websiteHome)
1069+ command = f'rsync -av { completPath } /public_html/ /home/{ masterDomain } '
1070+ else :
1071+ command = 'cp -R %s/public_html %s' % (completPath , websiteHome )
10581072 ProcessUtilities .executioner (command )
10591073
10601074 ## extracting email accounts
0 commit comments