From 7172fe3e19a11f786c4f3b6f0ad3a7499bd8a7b4 Mon Sep 17 00:00:00 2001 From: wangxy <1481820854@qq.com> Date: Mon, 21 Oct 2024 15:07:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=88=90=E7=BB=A9=E6=9C=80=E9=AB=98?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/monitor/BackupController.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/BackupController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/BackupController.java index cab9b19..170880b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/BackupController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/BackupController.java @@ -67,4 +67,29 @@ public class BackupController extends BaseController { return AjaxResult.error("备份失败!"); } } + + + @PostMapping("reduction") + @ResponseBody + public AjaxResult reduction(@RequestParam String username, + @RequestParam String password, + @RequestParam String hostname, + @RequestParam String port, + @RequestParam String databaseName) { + String sqlFileName = RuoYiConfig.getDataBaseBackUp() + ".sql"; + try { + //金仓数据库还原指令:ksql -f d:\bbb.sql "host=127.0.0.1 port=54321 user=root password=123456 dbname=test" + ProcessBuilder processBuilder = new ProcessBuilder("ksql", "-f", sqlFileName, + "\"host=" + hostname, "port=" + port, "user=" + username, "password=" + password, "dbname=" + databaseName + "\""); + Process process = processBuilder.start(); + if (process.waitFor() == 0) { + return AjaxResult.success("还原成功!"); + } else { + return AjaxResult.error("还原失败!"); + } + } catch (Exception e) { + e.printStackTrace(); + return AjaxResult.error("还原成功!"); + } + } }