Skip to content
Permalink
Browse files

bug fix backups: restore ssl

  • Loading branch information...
usmannasir committed Aug 31, 2019
1 parent bc2a05b commit 2405746166505ca036f5b87158cbf72ee3abfcdf
Showing with 52 additions and 49 deletions.
  1. +52 −49 plogical/backupUtilities.py
@@ -270,51 +270,6 @@ def startBackup(tempStoragePath, backupName, backupPath, metaPath = None):

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

##### Saving SSL Certificates if any

sslStoragePath = '/etc/letsencrypt/live/' + domainName

if os.path.exists(sslStoragePath):
try:
copy(os.path.join(sslStoragePath, "cert.pem"), os.path.join(tempStoragePath, domainName + ".cert.pem"))
copy(os.path.join(sslStoragePath, "fullchain.pem"), os.path.join(tempStoragePath, domainName + ".fullchain.pem"))
copy(os.path.join(sslStoragePath, "privkey.pem"), os.path.join(tempStoragePath, domainName + ".privkey.pem"))
except:
pass

## Child Domains SSL.


childDomains = backupMetaData.findall('ChildDomains/domain')

try:
for childDomain in childDomains:

actualChildDomain = childDomain.find('domain').text

if os.path.exists(backupUtilities.licenseKey):
completPathToConf = backupUtilities.Server_root + '/conf/vhosts/' + actualChildDomain + '/vhost.conf'
copy(completPathToConf, tempStoragePath + '/' + actualChildDomain + '.vhost.conf')

### Storing SSL for child domainsa

sslStoragePath = '/etc/letsencrypt/live/' + actualChildDomain

if os.path.exists(sslStoragePath):
try:
copy(os.path.join(sslStoragePath, "cert.pem"),
os.path.join(tempStoragePath, actualChildDomain + ".cert.pem"))
copy(os.path.join(sslStoragePath, "fullchain.pem"),
os.path.join(tempStoragePath, actualChildDomain + ".fullchain.pem"))
copy(os.path.join(sslStoragePath, "privkey.pem"),
os.path.join(tempStoragePath, actualChildDomain + ".privkey.pem"))
make_archive(os.path.join(tempStoragePath, "sslData-" + domainName), 'gztar',
sslStoragePath)
except:
pass
except BaseException, msg:
pass

logging.CyberCPLogFileWriter.statusWriter(status, "Backing up databases..")
print '1,None'

@@ -336,11 +291,59 @@ def startBackup(tempStoragePath, backupName, backupPath, metaPath = None):
@staticmethod
def BackupRoot(tempStoragePath, backupName, backupPath, metaPath=None):

## backup emails

status = os.path.join(backupPath, 'status')
metaPathInBackup = os.path.join(tempStoragePath, 'meta.xml')
backupMetaData = ElementTree.parse(metaPathInBackup)

domainName = backupMetaData.find('masterDomain').text
##### Saving SSL Certificates if any

sslStoragePath = '/etc/letsencrypt/live/' + domainName

if os.path.exists(sslStoragePath):
try:
copy(os.path.join(sslStoragePath, "cert.pem"), os.path.join(tempStoragePath, domainName + ".cert.pem"))
copy(os.path.join(sslStoragePath, "fullchain.pem"),
os.path.join(tempStoragePath, domainName + ".fullchain.pem"))
copy(os.path.join(sslStoragePath, "privkey.pem"),
os.path.join(tempStoragePath, domainName + ".privkey.pem"))
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile('%s. [283:startBackup]' % (str(msg)))

## Child Domains SSL.

childDomains = backupMetaData.findall('ChildDomains/domain')

try:
for childDomain in childDomains:

actualChildDomain = childDomain.find('domain').text

if os.path.exists(backupUtilities.licenseKey):
completPathToConf = backupUtilities.Server_root + '/conf/vhosts/' + actualChildDomain + '/vhost.conf'
copy(completPathToConf, tempStoragePath + '/' + actualChildDomain + '.vhost.conf')

### Storing SSL for child domainsa

sslStoragePath = '/etc/letsencrypt/live/' + actualChildDomain

if os.path.exists(sslStoragePath):
try:
copy(os.path.join(sslStoragePath, "cert.pem"),
os.path.join(tempStoragePath, actualChildDomain + ".cert.pem"))
copy(os.path.join(sslStoragePath, "fullchain.pem"),
os.path.join(tempStoragePath, actualChildDomain + ".fullchain.pem"))
copy(os.path.join(sslStoragePath, "privkey.pem"),
os.path.join(tempStoragePath, actualChildDomain + ".privkey.pem"))
make_archive(os.path.join(tempStoragePath, "sslData-" + domainName), 'gztar',
sslStoragePath)
except:
pass
except BaseException, msg:
pass

## backup emails

domainName = backupMetaData.find('masterDomain').text

if os.path.islink(status) or os.path.islink(tempStoragePath or os.path.islink(backupPath)) or os.path.islink(metaPath):
@@ -551,8 +554,8 @@ def startRestore(backupName, dir):
copy(completPath + "/" + masterDomain + ".fullchain.pem", sslHome + "/fullchain.pem")

sslUtilities.installSSLForDomain(masterDomain)
except:
pass
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile('%s. [555:startRestore]' % (str(msg)))

else:
logging.CyberCPLogFileWriter.statusWriter(status, "Error Message: " + result[1] + ". Not able to create Account, Databases and DNS Records, aborting. [5009]")

0 comments on commit 2405746

Please sign in to comment.
You can’t perform that action at this time.