Skip to content

Commit ed9a5e2

Browse files
committed
fixed a bug that cause restore fail if 1 user have access to more then 1 database
1 parent 7b5bdb6 commit ed9a5e2

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

plogical/backupUtilities.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -625,8 +625,10 @@ def createWebsiteFromBackup(backupFileOrig, dir):
625625
for databaseUser in databaseUsers:
626626

627627
dbUser = databaseUser.find('dbUser').text
628-
if mysqlUtilities.mysqlUtilities.createDatabase(dbName, dbUser, 'cyberpanel') == 0:
629-
raise BaseException
628+
res = mysqlUtilities.mysqlUtilities.createDatabase(dbName, dbUser, 'cyberpanel')
629+
if res == 0:
630+
logging.CyberCPLogFileWriter.writeToFile(
631+
'Failed to restore database %s. But it can be false positive, moving on..' % (dbName))
630632

631633
newDB = Databases(website=website, dbName=dbName, dbUser=dbUser)
632634
newDB.save()
@@ -903,10 +905,14 @@ def startRestore(backupName, dir):
903905
logging.CyberCPLogFileWriter.writeToFile('Database host: %s' % (dbHost))
904906
logging.CyberCPLogFileWriter.writeToFile('Database password: %s' % (password))
905907

908+
## Future ref, this logic can be further refactored to improve restore backup logic
906909
if first:
907910
first = 0
908-
if mysqlUtilities.mysqlUtilities.restoreDatabaseBackup(dbName, completPath, password, 1) == 0:
909-
raise BaseException
911+
res = mysqlUtilities.mysqlUtilities.restoreDatabaseBackup(dbName, completPath, password, 1)
912+
if res == 0:
913+
logging.CyberCPLogFileWriter.writeToFile(
914+
'Failed to restore database %s. But it can be false positive, moving on..' % (
915+
dbName))
910916

911917

912918
### This function will not create database, only database user is created as third value is 0 for createDB

0 commit comments

Comments
 (0)