diff --git a/Backup2Cloud/Backup2Cloud.csproj b/Backup2Cloud/Backup2Cloud.csproj
index c16a27c..45a4225 100644
--- a/Backup2Cloud/Backup2Cloud.csproj
+++ b/Backup2Cloud/Backup2Cloud.csproj
@@ -5,9 +5,9 @@
netcoreapp2.0
false
- 0.1.0.0
- 0.1.0.0
- 0.1.0
+ 0.2.0.0
+ 0.2.0.0
+ 0.2.0
sanjusss
定时将服务器上的文件备份到云存储。
diff --git a/Backup2Cloud/Conf/ExamplePrinter.cs b/Backup2Cloud/Conf/ExamplePrinter.cs
index 2353489..637cf2c 100644
--- a/Backup2Cloud/Conf/ExamplePrinter.cs
+++ b/Backup2Cloud/Conf/ExamplePrinter.cs
@@ -7,6 +7,7 @@
using System.Collections.Generic;
using System.IO;
using System.Text;
+using System.Linq;
namespace Backup2Cloud.Conf
{
@@ -106,14 +107,14 @@ private static string GetExampleConfig(Dictionary uploaders, Dicti
if (uploaders.Count > 0)
{
- var i = uploaders.GetEnumerator().Current;
+ var i = uploaders.First();
single.uploader = (Activator.CreateInstance(i.Value) as IUploader).GetExample() as IUploader;
single.name += i.Key;
}
if (dataSources.Count > 0)
{
- var i = dataSources.GetEnumerator().Current;
+ var i = dataSources.First();
single.dataSource = (Activator.CreateInstance(i.Value) as IDataSource).GetExample() as IDataSource;
}
diff --git a/Backup2Cloud/DataSource/FtpDataSource.cs b/Backup2Cloud/DataSource/FtpDataSource.cs
index 45d93b7..40acccd 100644
--- a/Backup2Cloud/DataSource/FtpDataSource.cs
+++ b/Backup2Cloud/DataSource/FtpDataSource.cs
@@ -1,6 +1,7 @@
using Backup2Cloud.Conf;
using Backup2Cloud.Logging;
using FluentFTP;
+using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
@@ -18,7 +19,12 @@ public string Tips
{
get
{
- return string.Empty;
+ return "host:服务器主机名;" +
+ "port:服务器的FTP端口;" +
+ "user:用户名;" +
+ "password:密码;" +
+ "anonymous:是否使用匿名登陆;" +
+ "path:在ftp上的路径,可以是文件或文件夹。";
}
}
@@ -41,7 +47,7 @@ public void SaveData(string des)
client.Connect();
if (client.DirectoryExists(path))
{
- int result = DownloadDirectory(path, "/", des, client);
+ int result = DownloadDirectory(path, "/", FormatDirectoryName(des), client);
Log.Print($"从 ftp://{ host }:{ port }{ path } 成功下载 { result } 个文件到 { des } 。");
}
else
@@ -96,7 +102,7 @@ private int DownloadDirectory(string baseSrc, string dir, string des, FtpClient
foreach (var i in dirs)
{
- result += DownloadDirectory(baseSrc, dir + i + "/", des + i + "/", client);
+ result += DownloadDirectory(baseSrc, dir + i + "/", des, client);
}
return result;
diff --git a/Backup2Cloud/Uploader/FtpUploader.cs b/Backup2Cloud/Uploader/FtpUploader.cs
index 67cbdc4..f9391dd 100644
--- a/Backup2Cloud/Uploader/FtpUploader.cs
+++ b/Backup2Cloud/Uploader/FtpUploader.cs
@@ -9,13 +9,22 @@
namespace Backup2Cloud.Uploader
{
+ ///
+ /// FTP上传实现类。
+ ///
+ [Name("ftp")]
public class FtpUploader : BaseFtpConf, IUploader
{
public string Tips
{
get
{
- return string.Empty;
+ return "host:服务器主机名;" +
+ "port:服务器的FTP端口;" +
+ "user:用户名;" +
+ "password:密码;" +
+ "anonymous:是否使用匿名登陆;" +
+ "path:在ftp上的路径前缀。";
}
}
diff --git a/README.md b/README.md
index 2dd9fae..98f963a 100644
--- a/README.md
+++ b/README.md
@@ -29,7 +29,7 @@
|[金山云](https://www.ksyun.com)|[对象存储](https://www.ksyun.com/post/product/KS3)|![不支持](https://img.shields.io/badge/support-No-red.svg)|仅限企业用户|
|[Azure](https://www.azure.cn/zh-cn/)|[Blob 存储](https://www.azure.cn/zh-cn/home/features/storage/blobs/)|![支持](https://img.shields.io/badge/support-Yes-green.svg)||
|[Google Cloud](https://cloud.google.com)|[Google Cloud Storage](https://cloud.google.com/storage/)|![支持](https://img.shields.io/badge/support-Yes-green.svg)||
-||FTP|![即将到来](https://img.shields.io/badge/support-Future-yellow.svg)||
+|自定义|FTP|![支持](https://img.shields.io/badge/support-Yes-green.svg)||
# 支持的数据源
@@ -41,8 +41,8 @@
|SQL Server|![即将到来](https://img.shields.io/badge/support-Future-yellow.svg)|
|Oracle|![即将到来](https://img.shields.io/badge/support-Future-yellow.svg)|
|自定义命令|![支持](https://img.shields.io/badge/support-Yes-green.svg)|
-|FTP文件|![即将到来](https://img.shields.io/badge/support-Future-yellow.svg)|
-|FTP文件文件夹|![即将到来](https://img.shields.io/badge/support-Future-yellow.svg)|
+|FTP文件|![支持](https://img.shields.io/badge/support-Yes-green.svg)|
+|FTP文件文件夹|![支持](https://img.shields.io/badge/support-Yes-green.svg)|
# 支持的备份触发方式
@@ -68,6 +68,7 @@ docker run --rm -v /D/share:/conf sanjusss/backup2cloud eg -s /conf/eg.json
运行后将在D:\share\eg.json生成示例配置文件。
如果省略`-s /conf/eg.json`,将不保存文件,仅在命令行下输出。
实际的配置文件中没有Tips一项。
+其他配置参数见[查看示例](https://github.com/sanjusss/backup2cloud#查看示例)。
# 使用方法(Windows)
### 下载
@@ -79,7 +80,8 @@ backup2cloud run -c D:\backup2cloud.json
```
运行后程序将加载配置文件backup2cloud.json。
-### 查看示例配置文件
+### 查看示例
+1. 查看一个示例配置文件
```
backup2cloud eg -s D:\share\eg.json
```
@@ -87,6 +89,27 @@ backup2cloud eg -s D:\share\eg.json
如果省略`-s D:\share\eg.json`,将不保存文件,仅在命令行下输出。
实际的配置文件中没有Tips一项。
+2. 查看所有上传类名称
+```
+backup2cloud eg -l uploader
+```
+
+3. 查看所有数据源类名称
+```
+backup2cloud eg -l datasource
+```
+
+4. 查看指定上传类示例
+```
+backup2cloud eg -u 上传类名称
+```
+
+5. 查看指定数据源类示例
+```
+backup2cloud eg -d 数据源类名称
+```
+
+
# 配置文件说明
待补充
diff --git a/appveyor.yml b/appveyor.yml
index 8319dda..683ab23 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,5 +1,5 @@
-version: 0.1.0.0.{build}
+version: 0.2.0.0.{build}
image: Visual Studio 2017
shallow_clone: true
build_script: