|
@@ -68,7 +68,7 @@ public class BackupIncreaseTask implements Runnable {
|
|
|
|
|
|
prlog=service.getLastBackup(log.getTaskName());
|
|
prlog=service.getLastBackup(log.getTaskName());
|
|
|
|
|
|
- service.createBackup(buildSQL(tab,log.getBackupFile()),getDataTime(prlog),log.getDataEndTime());
|
|
|
|
|
|
+ service.createBackup(buildSQL(tab,getDataTime(prlog),log.getDataEndTime(),log.getBackupFile()));
|
|
|
|
|
|
log.setStatus(BackupLogPO.STAT_SUCCESS);
|
|
log.setStatus(BackupLogPO.STAT_SUCCESS);
|
|
log.setEndTime(new Date());
|
|
log.setEndTime(new Date());
|
|
@@ -88,26 +88,32 @@ public class BackupIncreaseTask implements Runnable {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- private String buildSQL(String tab,String saveFile) {
|
|
|
|
|
|
+ private String buildSQL(String tab,Date startTime,Date endTime,String saveFile) {
|
|
String[] tabField=tab.split(":");
|
|
String[] tabField=tab.split(":");
|
|
StringBuilder sql=new StringBuilder();
|
|
StringBuilder sql=new StringBuilder();
|
|
sql.append("select * from "+tabField[0]);
|
|
sql.append("select * from "+tabField[0]);
|
|
- sql.append(" where "+tabField[1]+" > ? and "+tabField[1]+"<=? into outfile="+saveFile);
|
|
|
|
|
|
+ sql.append(" where "+tabField[1]+" > '"+DateUtil.format(startTime, "yyyy-MM-dd HH:mm:ss")+"' and "+tabField[1]+" <= '"+DateUtil.format(endTime, "yyyy-MM-dd HH:mm:ss")+"' into outfile '"+saveFile+"'");
|
|
return sql.toString();
|
|
return sql.toString();
|
|
}
|
|
}
|
|
|
|
|
|
private BackupLogPO buildLog(String tab) throws IOException {
|
|
private BackupLogPO buildLog(String tab) throws IOException {
|
|
tab=tab.split(":")[0];
|
|
tab=tab.split(":")[0];
|
|
- String fileName=sche.getScheduleName()+"["+tab+"]";
|
|
|
|
|
|
+ String fileName="["+tab+"]"; //sche.getScheduleName()+"["+tab+"]";
|
|
|
|
|
|
BackupLogPO backupLog=new BackupLogPO(fileName,sche.getScheduleId(),BackupLogPO.STAT_RUNNING);
|
|
BackupLogPO backupLog=new BackupLogPO(fileName,sche.getScheduleId(),BackupLogPO.STAT_RUNNING);
|
|
|
|
|
|
String path=properties.getSavePath();
|
|
String path=properties.getSavePath();
|
|
- if(!path.endsWith(File.separator)) {
|
|
|
|
|
|
+
|
|
|
|
+ //sql语句中的分隔符特殊处理
|
|
|
|
+
|
|
|
|
+ /*if(!path.endsWith(File.separator)) {
|
|
path+=File.separator;
|
|
path+=File.separator;
|
|
}
|
|
}
|
|
|
|
|
|
path+=DateUtil.format(new Date(), "yyyyMM")+File.separator;
|
|
path+=DateUtil.format(new Date(), "yyyyMM")+File.separator;
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ path+="\\\\"+DateUtil.format(new Date(), "yyyyMM")+"\\\\";
|
|
|
|
|
|
FileUtils.forceMkdir(new File(path));
|
|
FileUtils.forceMkdir(new File(path));
|
|
|
|
|