mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-01-23 22:42:15 +08:00
add sync command
This commit is contained in:
parent
979b3d9bde
commit
232ab535ed
@ -35,7 +35,7 @@ func CmdSync() cli.Command {
|
||||
UsageText: cmder.App().Name + " sync",
|
||||
Description: `
|
||||
备份功能。指定本地目录和对应的一个网盘目录,以备份文件。
|
||||
备份功能支持一下三种模式:
|
||||
备份功能支持以下三种模式:
|
||||
1. upload
|
||||
备份本地文件,即上传本地文件到网盘,始终保持本地文件有一个完整的备份在网盘
|
||||
2. download
|
||||
@ -43,12 +43,51 @@ func CmdSync() cli.Command {
|
||||
3. sync
|
||||
双向备份,保持网盘文件和本地文件严格一致
|
||||
|
||||
示例:
|
||||
1. 启动同步备份任务
|
||||
aliyunpan-go sync start
|
||||
请输入以下命令查看如何配置和启动:
|
||||
aliyunpan sync start -h
|
||||
`,
|
||||
Category: "阿里云盘",
|
||||
Before: cmder.ReloadConfigFunc,
|
||||
Action: func(c *cli.Context) error {
|
||||
cli.ShowCommandHelp(c, c.Command.Name)
|
||||
return nil
|
||||
},
|
||||
Subcommands: []cli.Command{
|
||||
{
|
||||
Name: "start",
|
||||
Usage: "启动sync同步备份任务",
|
||||
UsageText: cmder.App().Name + " sync start [arguments...]",
|
||||
Description: `
|
||||
使用备份配置文件启动sync同步备份任务。备份配置文件必须存在,不然启动失败。
|
||||
同步备份任务的配置文件保存在:(配置目录)/sync_drive/sync_drive_config.json,样例如下:
|
||||
{
|
||||
"configVer": "1.0",
|
||||
"syncTaskList": [
|
||||
{
|
||||
"name": "设计文档备份",
|
||||
"localFolderPath": "D:\\tickstep\\Documents\\设计文档",
|
||||
"panFolderPath": "/sync_drive/我的文档",
|
||||
"mode": "upload"
|
||||
}
|
||||
]
|
||||
}
|
||||
相关字段说明如下:
|
||||
name - 任务名称
|
||||
localFolderPath - 本地目录
|
||||
panFolderPath - 网盘目录
|
||||
mode - 模式: upload(备份本地文件到云盘),download(备份云盘文件到本地),sync(双向同步备份)
|
||||
|
||||
例子:
|
||||
1. 查看帮助
|
||||
aliyunpan sync start -h
|
||||
|
||||
2. 使用默认配置启动同步备份服务
|
||||
aliyunpan sync start
|
||||
|
||||
3. 启动sync服务,并配置下载并发为2,上传并发为1,上传分片大小为1MB
|
||||
aliyunpan sync start -dp 2 -up 1 -ubs 1024
|
||||
|
||||
`,
|
||||
Action: func(c *cli.Context) error {
|
||||
if config.Config.ActiveUser() == nil {
|
||||
fmt.Println("未登录账号")
|
||||
@ -80,7 +119,7 @@ func CmdSync() cli.Command {
|
||||
uploadBlockSize = aliyunpan.DefaultChunkSize
|
||||
}
|
||||
|
||||
RunSync(up, dp, uploadBlockSize, downloadBlockSize)
|
||||
RunSync(dp, up, downloadBlockSize, uploadBlockSize)
|
||||
return nil
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
@ -100,6 +139,8 @@ func CmdSync() cli.Command {
|
||||
Value: 10240,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user