perf:数据库备份
This commit is contained in:
@@ -22,7 +22,7 @@ public class DbBackupConfig {
|
|||||||
/**
|
/**
|
||||||
* 数据库备份的路径
|
* 数据库备份的路径
|
||||||
*/
|
*/
|
||||||
private String path = "/Users/hao/Downloads/backup/";
|
private String path = "/root/backup/";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 备份文件的时间格式
|
* 备份文件的时间格式
|
||||||
@@ -42,7 +42,7 @@ public class DbBackupConfig {
|
|||||||
try {
|
try {
|
||||||
String saveFile = StrUtil.format("{}{}/{}.sql.gz", getPath(), dbName, DateUtil.format(new Date(), format));
|
String saveFile = StrUtil.format("{}{}/{}.sql.gz", getPath(), dbName, DateUtil.format(new Date(), format));
|
||||||
FileUtil.mkParentDirs(saveFile);
|
FileUtil.mkParentDirs(saveFile);
|
||||||
String cmd = StrUtil.format("mysqldump -u{} -p{} {} | gzip > {}", username, password, dbName, saveFile);
|
String cmd = StrUtil.format("mysqldump -u{} -p'{}' {} | gzip > {}", username, password, dbName, saveFile);
|
||||||
LogFactory.get().info("cmd: " + cmd);
|
LogFactory.get().info("cmd: " + cmd);
|
||||||
String forStr = RuntimeUtil.execForStr(cmd);
|
String forStr = RuntimeUtil.execForStr(cmd);
|
||||||
LogFactory.get().info("dbBackup: " + forStr);
|
LogFactory.get().info("dbBackup: " + forStr);
|
||||||
|
|||||||
Reference in New Issue
Block a user