diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 2c54bcca1..003aab3ce 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -71,6 +71,13 @@ def checkArgs(data, ck=[]): return (True, mw.returnJson(True, 'ok')) +def getBackupDir(): + bk_path = mw.getBackupDir() + "/database/mariadb" + if not os.path.isdir(bk_path): + mw.execShell("mkdir -p {}".format(bk_path)) + return bk_path + + def getConf(): path = getServerDir() + '/etc/my.cnf' return path @@ -675,7 +682,7 @@ def __createUser(dbname, username, password, address): def getDbBackupListFunc(dbname=''): - bkDir = mw.getRootDir() + '/backup/database/mariadb' + bkDir = getBackupDir() blist = os.listdir(bkDir) r = [] @@ -709,9 +716,8 @@ def importDbBackup(): file = args['file'] name = args['name'] - file_path = mw.getBackupDir() + '/database/mariadb/' + file - file_path_sql = mw.getBackupDir() + '/database/mariadb/' + \ - file.replace('.gz', '') + file_path = getBackupDir() + '/' + file + file_path_sql = getBackupDir() + '/' + file.replace('.gz', '') if not os.path.exists(file_path_sql): cmd = 'cd ' + mw.getBackupDir() + '/database/mariadb && gzip -d ' + file @@ -798,7 +804,7 @@ def deleteDbBackup(): path = args['path'] full_file = "" - bkDir = mw.getRootDir() + '/backup/database/mariadb' + bkDir = getBackupDir() full_file = bkDir + '/' + args['filename'] if path != "": full_file = path + "/" + args['filename'] @@ -813,7 +819,7 @@ def getDbBackupList(): return data[1] r = getDbBackupListFunc(args['name']) - bkDir = mw.getBackupDir() + '/database/mariadb' + bkDir = getBackupDir() if not os.path.exists(bkDir): os.mkdir(bkDir) diff --git a/plugins/mysql-apt/index.py b/plugins/mysql-apt/index.py index 2105f57a3..c9a3cfb39 100755 --- a/plugins/mysql-apt/index.py +++ b/plugins/mysql-apt/index.py @@ -67,6 +67,13 @@ def getArgs(): return tmp +def getBackupDir(): + bk_path = mw.getBackupDir() + "/database/mysql-apt" + if not os.path.isdir(bk_path): + mw.execShell("mkdir -p {}".format(bk_path)) + return bk_path + + def checkArgs(data, ck=[]): for i in range(len(ck)): if not ck[i] in data: @@ -651,7 +658,7 @@ def __createUser(dbname, username, password, address): def getDbBackupListFunc(dbname=''): - bkDir = mw.getBackupDir() + '/database/mysql-apt' + bkDir = getBackupDir() if not os.path.exists(bkDir): os.mkdir(bkDir) @@ -688,7 +695,7 @@ def importDbExternal(): file = args['file'] name = args['name'] - import_dir = mw.getBackupDir() + '/import/mysql-apt' + import_dir = mw.getBackupDir() + '/import/' file_path = import_dir + file if not os.path.exists(file_path): @@ -779,7 +786,7 @@ def deleteDbBackup(): path = args['path'] full_file = "" - bkDir = mw.getBackupDir() + '/database/mysql-apt' + bkDir = getBackupDir() full_file = bkDir + '/' + args['filename'] if path != "": full_file = path + "/" + args['filename'] @@ -794,7 +801,7 @@ def getDbBackupList(): return data[1] r = getDbBackupListFunc(args['name']) - bkDir = mw.getBackupDir() + '/database/mysql-apt' + bkDir = getBackupDir() rr = [] for x in range(0, len(r)): p = bkDir + '/' + r[x] diff --git a/plugins/mysql-yum/index.py b/plugins/mysql-yum/index.py index 7731b1a1f..0a9754f3d 100755 --- a/plugins/mysql-yum/index.py +++ b/plugins/mysql-yum/index.py @@ -65,6 +65,13 @@ def checkArgs(data, ck=[]): return (True, mw.returnJson(True, 'ok')) +def getBackupDir(): + bk_path = mw.getBackupDir() + "/database/mysql-yum" + if not os.path.isdir(bk_path): + mw.execShell("mkdir -p {}".format(bk_path)) + return bk_path + + def getConf(): path = getServerDir() + '/etc/my.cnf' return path @@ -629,7 +636,7 @@ def __createUser(dbname, username, password, address): def getDbBackupListFunc(dbname=''): - bkDir = mw.getBackupDir() + '/database/mysql-yum' + bkDir = getBackupDir() blist = os.listdir(bkDir) r = [] @@ -729,8 +736,8 @@ def importDbBackup(): file = args['file'] name = args['name'] - file_path = mw.getBackupDir() + '/database/' + file - file_path_sql = mw.getBackupDir() + '/database/' + file.replace('.gz', '') + file_path = getBackupDir() + '/' + file + file_path_sql = getBackupDir() + '/' + file.replace('.gz', '') if not os.path.exists(file_path_sql): cmd = 'cd ' + mw.getBackupDir() + '/database && gzip -d ' + file @@ -754,7 +761,7 @@ def deleteDbBackup(): path = args['path'] full_file = "" - bkDir = mw.getBackupDir() + '/database/mysql-yum' + bkDir = getBackupDir() full_file = bkDir + '/' + args['filename'] if path != "": full_file = path + "/" + args['filename'] @@ -769,7 +776,7 @@ def getDbBackupList(): return data[1] r = getDbBackupListFunc(args['name']) - bkDir = mw.getBackupDir() + '/database/mysql-yum' + bkDir = getBackupDir() rr = [] for x in range(0, len(r)): p = bkDir + '/' + r[x] diff --git a/plugins/postgresql/index.html b/plugins/postgresql/index.html index 3780f21c3..19647e423 100755 --- a/plugins/postgresql/index.html +++ b/plugins/postgresql/index.html @@ -1,3 +1,30 @@ +
diff --git a/plugins/postgresql/index.py b/plugins/postgresql/index.py index 389feeb95..307a2447a 100755 --- a/plugins/postgresql/index.py +++ b/plugins/postgresql/index.py @@ -70,7 +70,7 @@ def getArgs(): def getBackupDir(): - bk_path = mw.getBackupDir() + "/databases/postgresql" + bk_path = mw.getBackupDir() + "/database/postgresql" if not os.path.isdir(bk_path): mw.execShell("mkdir -p {}".format(bk_path)) return bk_path