perf:数据库备份
This commit is contained in:
@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.RuntimeUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.db.DbUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.hutool.log.LogFactory;
|
||||
import com.tiesheng.database.utls.TieshengDbUtil;
|
||||
@@ -42,7 +43,7 @@ public class DbBackupConfig {
|
||||
try {
|
||||
String saveFile = StrUtil.format("{}{}/{}.sql.gz", getPath(), dbName, DateUtil.format(new Date(), format));
|
||||
FileUtil.mkParentDirs(saveFile);
|
||||
String cmd = StrUtil.format("mysqldump -u{} -p'{}' {} | gzip > {}", username, password, dbName, saveFile);
|
||||
String cmd = StrUtil.format("mysqldump -h127.0.0.1 -u{} -p'{}' {} | gzip > {}", username, password, dbName, saveFile);
|
||||
LogFactory.get().info("cmd: " + cmd);
|
||||
String forStr = RuntimeUtil.execForStr(cmd);
|
||||
LogFactory.get().info("dbBackup: " + forStr);
|
||||
|
||||
Reference in New Issue
Block a user