From 71b64b19a1cd301e383c71b7cc96bb5beaf8cd7f Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Sun, 5 May 2024 13:51:59 +0800 Subject: [PATCH] Update index.py --- plugins/mongodb/index.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/plugins/mongodb/index.py b/plugins/mongodb/index.py index d5bdd388b..62dbf7df0 100755 --- a/plugins/mongodb/index.py +++ b/plugins/mongodb/index.py @@ -1167,6 +1167,8 @@ def importDbBackup(): file = args['file'] name = args['name'] + port = getConfPort() + file_tgz = mw.getRootDir() + '/backup/database/' + file file_dir = mw.getRootDir() + '/backup/database/' + file.replace('.tar.gz','') @@ -1179,20 +1181,14 @@ def importDbBackup(): # print(cmd) mw.execShell(cmd) + cmd = getServerDir() + "/bin/mongorestore --port "+str(port)+" --dir "+file_dir + # print(cmd) + mw.execShell(cmd) - cmd = getServerDir() + "/bin/mongorestore --port 27017 --oplogReplay --dir "+file_dir - print(cmd) - # mw.execShell(cmd) - - - # pwd = pSqliteDb('config').where('id=?', (1,)).getField('mg_root') - - # print(mysql_cmd) - # os.system(mysql_cmd) - # rdata = mw.execShell(mysql_cmd) - # if rdata[1].lower().find('error') > -1: - # return mw.returnJson(False, rdata[1]) + # 删除文件 + del_cmd = "rm -rf "+file_dir + mw.execShell(del_cmd) return mw.returnJson(True, 'ok')