|
|
|
@ -20,17 +20,18 @@ public class MysqlRestoreUtil {
|
|
|
|
|
|
|
|
|
|
public MysqlRestoreUtil() {
|
|
|
|
|
// 从配置文件读取配置
|
|
|
|
|
this.obsEndpoint = PropKit.get("obs.endPoint");
|
|
|
|
|
this.obsAccessKey = PropKit.get("obs.accessKey");
|
|
|
|
|
this.obsSecretKey = PropKit.get("obs.secretKey");
|
|
|
|
|
this.obsBucket = PropKit.get("obs.bucketName");
|
|
|
|
|
this.obsEndpoint = PropKit.get("obs_endpoint");
|
|
|
|
|
this.obsAccessKey = PropKit.get("obs_accessKeyId");
|
|
|
|
|
this.obsSecretKey = PropKit.get("obs_accessKeySecret");
|
|
|
|
|
this.obsBucket = PropKit.get("obs_bucket_name");
|
|
|
|
|
|
|
|
|
|
// 目标数据库配置
|
|
|
|
|
this.dbHost = CommonUtil.getHostFromJdbcUrl(PropKit.get("write.jdbcUrl"));
|
|
|
|
|
this.dbPort = CommonUtil.getPortFromJdbcUrl(PropKit.get("write.jdbcUrl"));
|
|
|
|
|
String jdbcUrl=PropKit.get("write.jdbcUrl");
|
|
|
|
|
this.dbHost = CommonUtil.getHostFromJdbcUrl(jdbcUrl);
|
|
|
|
|
this.dbPort = CommonUtil.getPortFromJdbcUrl(jdbcUrl);
|
|
|
|
|
this.dbUser = PropKit.get("write.user");
|
|
|
|
|
this.dbPassword = PropKit.get("write.password");
|
|
|
|
|
this.dbName = CommonUtil.getDatabaseFromJdbcUrl(PropKit.get("write.jdbcUrl"));
|
|
|
|
|
this.dbName = CommonUtil.getDatabaseFromJdbcUrl(jdbcUrl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -100,11 +101,9 @@ public class MysqlRestoreUtil {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (extractedFile == null) {
|
|
|
|
|
throw new RuntimeException("ZIP文件中没有找到SQL文件");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return extractedFile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -159,9 +158,8 @@ public class MysqlRestoreUtil {
|
|
|
|
|
// 等待命令执行完成
|
|
|
|
|
int exitCode = process.waitFor();
|
|
|
|
|
if (exitCode != 0) {
|
|
|
|
|
throw new RuntimeException("数据库还原失败:\n" + errorOutput.toString());
|
|
|
|
|
throw new RuntimeException("数据库还原失败:\n" + errorOutput);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new RuntimeException("还原数据库失败: " + e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
|