From fdfe2e692bce4b523d32ed7adba5711bb2ba04cb Mon Sep 17 00:00:00 2001
From: lxw <810412026@qq.com>
Date: 星期四, 14 七月 2022 17:10:02 +0800
Subject: [PATCH] 定时备份数据

---
 src/main/java/com/whyc/service/FtpService.java |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/whyc/service/FtpService.java b/src/main/java/com/whyc/service/FtpService.java
index 1f768c9..2bb77f5 100644
--- a/src/main/java/com/whyc/service/FtpService.java
+++ b/src/main/java/com/whyc/service/FtpService.java
@@ -3,12 +3,14 @@
 import com.whyc.constant.YamlProperties;
 import com.whyc.dto.FileDirPath;
 import com.whyc.dto.FtpHelper;
+import com.whyc.dto.ZipUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 
 import java.io.File;
+import java.io.FileOutputStream;
 
 @Service
 @EnableScheduling   // 2.寮�鍚畾鏃朵换鍔�
@@ -17,14 +19,16 @@
     private FtpHelper ftpHelper;
 
     //瀹氭椂涓婁紶鎸囧畾鐩綍涓嬫枃浠�
-    @Scheduled(cron = "0/20 41 16 * * ?")
+    @Scheduled(cron = "0/20 06 17 * * ?")
     private void sendFtpFile(){
         FtpHelper ftp = new FtpHelper(YamlProperties.ftpIp, YamlProperties.ftpPort, YamlProperties.ftpUserName, YamlProperties.ftpPassword);
         String fileDirName = FileDirPath.getFileDirName();
         String root=fileDirName+File.separator+"face";
-        File file = new File(root+File.separator+"2.doc");
         try {
-            ftp.uploadFile(file, "test/2.doc");
+            FileOutputStream fos = new FileOutputStream(new File(root+".zip"));
+            ZipUtils.toZip(root, fos,true);
+            File file = new File(root+".zip");
+            ftp.uploadFile(file, "face.zip");
         } catch (Exception e) {
             e.printStackTrace();
         }

--
Gitblit v1.9.1