This commit is contained in:
2026-11-02 22:01:40 +08:00
parent 55df1b7613
commit 42bfd9a934
4 changed files with 18 additions and 12 deletions

View File

@@ -1275,7 +1275,7 @@ def replClose():
return mw.returnJson(True, '关闭副本同步成功!')
def getDbBackupListFunc(dbname=''):
bkDir = mw.getBackupDir() + '/database'
bkDir = mw.getBackupDir() + '/database/mongodb'
blist = os.listdir(bkDir)
r = []
@@ -1294,7 +1294,7 @@ def getDbBackupList():
return data[1]
r = getDbBackupListFunc(args['name'])
bkDir = mw.getBackupDir() + '/database'
bkDir = mw.getBackupDir() + '/database/mongodb'
rr = []
for x in range(0, len(r)):
p = bkDir + '/' + r[x]
@@ -1370,6 +1370,7 @@ def setDbBackup():
scDir = mw.getPanelDir() + '/scripts/backup.py'
head = "cd "+mw.getPanelDir()
cmd = head +' && . bin/activate && python3 plugins/mongodb/scripts/backup.py database ' + args['name'] + ' 3'
# print(cmd)
os.system(cmd)
return mw.returnJson(True, 'ok')
@@ -1390,7 +1391,7 @@ def getListBson(dbname=''):
def getListBsonByDatabase(dbname=''):
bkDir = mw.getBackupDir() + '/database/'+dbname
bkDir = mw.getBackupDir() + '/database/mongodb/'+dbname
blist = os.listdir(bkDir)
r = []
@@ -1586,7 +1587,7 @@ def importDbBackupProgressBar():
file = args['file']
name = args['name']
import_dir = mw.getFatherDir() + '/backup/database/'
import_dir = mw.getFatherDir() + '/backup/database/mongodb/'
port = getConfPort()
file_path = import_dir + file

View File

@@ -176,7 +176,7 @@ class backupTools:
print("----------------------------------------------------------------------------")
return
backup_path = mw.getBackupDir() + '/database'
backup_path = mw.getBackupDir() + '/database/mongodb'
if not os.path.exists(backup_path):
mw.execShell("mkdir -p " + backup_path)

View File

@@ -48,6 +48,7 @@ class backupTools:
def recognizeDbMode(self, mtype='mysql'):
conf = self.getConf(mtype)
# print(conf)
con = mw.readFile(conf)
rep = r"!include %s/(.*)?\.cnf" % (mw.getServerDir() +'/'+ mtype +"/etc/mode",)
mode = 'none'
@@ -100,14 +101,16 @@ class backupTools:
mw.writeFile(db_path + '/etc/my.cnf', mycnf)
option = ''
mode = self.recognizeDbMode('mysql')
if mode == 'gtid':
option = ' --set-gtid-purged=off '
# mode = self.recognizeDbMode('mysql-community')
# print(mode)
# if mode == 'gtid':
option = ' --set-gtid-purged=off '
cmd = db_path + "/bin/mysqldump --defaults-file=" + my_conf_path + " " + option + " --single-transaction -q --default-character-set=utf8mb4 " + name + " | gzip > " + filename
if table_name != '':
cmd = db_path + "/bin/mysqldump --defaults-file=" + my_conf_path + " " + option + " --single-transaction -q --default-character-set=utf8mb4 " + name + " " + table_name + " | gzip > " + filename
# print(cmd)
os.system(cmd)
# mw.execShell(cmd)

View File

@@ -188,10 +188,12 @@ class backupTools:
# 开启一致性事务 会lock表
# cmd = db_path + "/bin/mysqldump --defaults-file=" + my_cnf + " --force --opt --default-character-set=utf8 " + \
# name + " | gzip > " + filename
option = ''
mode = self.recognizeDbMode('mysql')
if mode == 'gtid':
option = ' --set-gtid-purged=off '
option = ' --set-gtid-purged=off '
# option = ''
# mode = self.recognizeDbMode('mysql')
# if mode == 'gtid':
# option = ' --set-gtid-purged=off '
# skip-opt 不会lock表
# --skip-opt --create-options