From 79004d812d6fbaceab22f64a2776cbc831ba416c Mon Sep 17 00:00:00 2001
From: whyclj <1525436766@qq.com>
Date: 星期五, 26 七月 2019 10:47:09 +0800
Subject: [PATCH] 备份数据的时候将数据库备份文件压缩后远程备份

---
 BattMonitor_FBS9100S_DataBaseBackUp/src/com/backup/DataBaseBackUpThread.java |   21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/BattMonitor_FBS9100S_DataBaseBackUp/src/com/backup/DataBaseBackUpThread.java b/BattMonitor_FBS9100S_DataBaseBackUp/src/com/backup/DataBaseBackUpThread.java
index 6dc0933..d7f9348 100644
--- a/BattMonitor_FBS9100S_DataBaseBackUp/src/com/backup/DataBaseBackUpThread.java
+++ b/BattMonitor_FBS9100S_DataBaseBackUp/src/com/backup/DataBaseBackUpThread.java
@@ -73,9 +73,17 @@
 					lastRecodTime = nowTime;
 					DataBaseBackUpThread_SQL.inseartBackupTable(pool,list);
 					
+					ZipUtil zipUtil = new ZipUtil();
+					String zipName = path+".zip";
+					File zipFile = zipUtil.createZip(zipName, new File(path));	//压缩数据库文件
+					
+					
 					HzipSocket SocketClient = new HzipSocket();
-					SocketClient.init(path);							//发送数据库备份文件到远程服务器
+					SocketClient.init(zipName);							//发送数据库备份文件到远程服务器
 					System.out.println("远程备份数据库完成" + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
+					if(zipFile.exists() && zipFile.length() > 1*1024 && new File(path).exists()) {
+						deleteDir(new File(path));
+					}
 				}
 				
 				//查询所有需要备份指定数据库的记录
@@ -102,8 +110,15 @@
 							table.setBack_en(DatabaseTable.MYSQL_BACKUP_OVER);										//备份完成
 							DataBaseBackUpThread_SQL.UpdateDataBaseState(pool, table);
 						}
-					}
+					}					
+					
 					if( count > 0) {
+						ZipUtil zipUtil = new ZipUtil();
+						String zipName = path+".zip";
+						File zipFile = zipUtil.createZip(zipName, new File(path));	//压缩数据库文件
+						if(zipFile.exists() && zipFile.length() > 1*1024 && new File(path).exists()) {
+							deleteDir(new File(path));
+						}
 						System.out.println("开始备份"+count+"个表    at "+Com.getDateTimeFormat(nowTime, Com.DTF_YMD_h_m_s));
 					}
 				}				
@@ -119,7 +134,7 @@
 	 * @return
 	 */
 	public static Date createNomalDate(Date time) {
-		String time_str = Com.getDateTimeFormat(time, Com.DTF_YMD) + " 23:59:30";
+		String time_str = Com.getDateTimeFormat(time, Com.DTF_YMD) + " 10:36:30";
 		//System.out.println(time_str);
 		return Com.getDateTimeFromStr(time_str, Com.DTF_YMDhms);
 	}

--
Gitblit v1.9.1