| | |
| | | import java.util.regex.Pattern;
|
| | |
|
| | | import com.base.Com;
|
| | | import com.config.AppConfig;
|
| | | import com.sql.MysqlConnPool;
|
| | |
|
| | | import main.main_FBS9100S_DataBaseBackUp;
|
| | |
| | | private MysqlConnPool pool;
|
| | | private String savePath = System.getProperty("user.dir")+ File.separator+"mysql_backup"; //备份数据库的根目录
|
| | | private MyRunTime runtime = null;
|
| | | private AppConfig appcfg;
|
| | |
|
| | | public DataBaseBackUpThread(MysqlConnPool conn_pool){
|
| | | public DataBaseBackUpThread(MysqlConnPool conn_pool,AppConfig appcfg){
|
| | | this.pool = conn_pool;
|
| | | this.appcfg = appcfg;
|
| | | |
| | | this.runtime = new MyRunTime(this.pool);
|
| | |
|
| | | DataBaseBackUpThread_SQL.createBackupTable(pool); //初始化数据库表
|
| | |
| | | //System.out.println();
|
| | |
|
| | | //12点59分开始备份所有的数据库
|
| | | if(countTimeLong(nowTime, normTime)<30 && countTimeLong(lastRecodTime, nowTime) >= 7*24*60*60) {
|
| | | if(countTimeLong(nowTime, normTime)<30 || countTimeLong(lastRecodTime, nowTime) >= 7*24*60*60) {
|
| | | System.out.println("开始备份所有的数据库"+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
|
| | | this.list = DataBaseBackUpThread_SQL.searchAllDataBaseAndTable(pool);
|
| | | String path = savePath+File.separator+REGULAR_BACKUP_PATHNAME;
|
| | |
| | | File zipFile = zipUtil.createZip(zipName, new File(path)); //压缩数据库文件
|
| | |
|
| | |
|
| | | HzipSocket SocketClient = new HzipSocket();
|
| | | HzipSocket SocketClient = new HzipSocket(appcfg);
|
| | | SocketClient.init(zipName); //发送数据库备份文件到远程服务器
|
| | | System.out.println("远程备份数据库完成" + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
|
| | | if(zipFile.exists() && zipFile.length() > 1*1024 && new File(path).exists()) {
|
| | |
| | | * @return
|
| | | */
|
| | | public static Date createNomalDate(Date time) {
|
| | | String time_str = Com.getDateTimeFormat(time, Com.DTF_YMD) + " 10:36:30";
|
| | | String time_str = Com.getDateTimeFormat(time, Com.DTF_YMD) + " 23:59:30";
|
| | | //System.out.println(time_str);
|
| | | return Com.getDateTimeFromStr(time_str, Com.DTF_YMDhms);
|
| | | }
|