Skip to content
Permalink
Browse files
preserve site user while backup/restore
  • Loading branch information
usmannasir committed Feb 13, 2020
1 parent 5748ad5 commit 7a7f99f00f2389a9cdd46b658a06fe9b9524887b
Showing 1 changed file with 35 additions and 2 deletions.
@@ -112,6 +112,12 @@ def prepareBackupMeta(backupDomain, backupName, tempStoragePath, backupPath):
child = SubElement(metaFileXML, 'state')
child.text = siteUser.state

child = SubElement(metaFileXML, 'initWebsitesLimit')
child.text = str(siteUser.initWebsitesLimit)

child = SubElement(metaFileXML, 'aclName')
child.text = siteUser.acl.name

#####################

childDomains = website.childdomains_set.all()
@@ -516,6 +522,33 @@ def createWebsiteFromBackup(backupFileOrig, dir):
phpSelection = backupMetaData.find('phpSelection').text
externalApp = backupMetaData.find('externalApp').text

### Fetch user details

userName = backupMetaData.find('userName').text

try:
siteUser = Administrator.objects.get(userName=userName)
except:
userPassword = backupMetaData.find('userPassword').text
firstName = backupMetaData.find('firstName').text
lastName = backupMetaData.find('lastName').text
email = backupMetaData.find('email').text
type = int(backupMetaData.find('type').text)
owner = int(backupMetaData.find('owner').text)
token = backupMetaData.find('token').text
api = int(backupMetaData.find('api').text)
securityLevel = int(backupMetaData.find('securityLevel').text)
state = backupMetaData.find('state').text
initWebsitesLimit = int(backupMetaData.find('initWebsitesLimit').text)
from loginSystem.models import ACL
acl = ACL.objects.get(name=backupMetaData.find('aclName').text)
siteUser = Administrator(userName=userName, password=userPassword, firstName=firstName,
initWebsitesLimit=initWebsitesLimit, acl=acl,
lastName=lastName, email=email, type=type, owner=owner, token=token,
api=api, securityLevel=securityLevel, state=state)
siteUser.save()


## Pre-creation checks

if Websites.objects.filter(domain=domain).count() > 0:
@@ -531,8 +564,8 @@ def createWebsiteFromBackup(backupFileOrig, dir):

## Create Configurations

result = virtualHostUtilities.createVirtualHost(domain, admin.email, phpSelection, externalApp, 0, 1, 0,
admin.userName, 'Default', 0)
result = virtualHostUtilities.createVirtualHost(domain, siteUser.email, phpSelection, externalApp, 0, 1, 0,
siteUser.userName, 'Default', 0)

if result[0] == 0:
raise BaseException(result[1])

0 comments on commit 7a7f99f

Please sign in to comment.