软件版本

服务端:cwRsyncServer_4.1.0_Installer.exe

客户端:cwRsync_4.1.0_Installer.exe

应用场景

服务端:windows server 2016   IP : 192.168.67.1

客户端:windows10                   IP : 192.168.67.2

每次打开我的windows10时,自动同步server端的指定目录到本机,并且要在联网的情况下才同步文件。

服务端安装

运行 cwRsyncServer_4.0.5_Installer.exe ,一步步默认安装完毕后,

安装目录在 C:\Program Files (x86)\ICW

配置文件 rsyncd.conf 默认内容如下

use chroot = false
strict modes = false
hosts allow = *
log file = rsyncd.log# Module definitions
# Remember cygwin naming conventions : c:\work becomes /cygwin/c/work
#
[test]
path = /cygdrive/c/work
read only = false
transfer logging = yes

其中

hosts allow  -- 设定允许访问本服务端的客户端的IP, *代表任何客户端都可以访问。

[test] -- 是一个初始的模块

path -- 模块对应的文件路径,这里work后面有没有正向斜线"/"都一样。后面客户端的中的斜线比较重要。

read only  -- 设置目录是否只读

transfer logging  -- 是否记录日志

现在,我打算修改原来的配置

uid = 0
gid = 0
use chroot = false
strict modes = false
hosts allow = *
log file = rsyncd.log[Repositories]
path =  /cygdrive/d/backup/Repositories
secrets file = /cygdrive/c/Program Files (x86)/ICW/rsyncd.secrets
list = true
auth users = user01
read only = false

上面我增加了

uid = 0 和 gid = 0 -- 如果不增加,从linux下同步文件过来会有损坏。

secrets file -- 该文件保存客户端使用的用户和密码

/cygdrive/c/ICW/rsyncd.secrets 是unix风格的文件路径,对应windows下的文件路径为 C:\Program Files (x86)\ICW\rsyncd.secrets,并且 rsyncd.secrets默认没有的,需要手动建立,文件内容的格式如:“username:password”

Windows Server 对权限管理更严格,服务端存放文件的目录需要做一定修改,将安装cwRsyncServer_4.0.5_Installer.exe时创建的服务器运行用户 SvcCWRSYNC 添加到该文件夹的用户列表里,并赋予全部权限。

在服务管理器中,名称为 RsyncServer ,将其启动类型设置为 自动。

最后启动服务。

服务端的默认监听端口为 873,若是想修改端口,只需要在服务端配置文件里的模块下指定--port=PORT即可。

所以还需要在防火墙里开启873端口。

客户端安装

运行 cwRsync_4.1.0_Installer.exe ,一步步默认安装完毕后,

安装目录在 C:\Program Files (x86)\cwRsync

客户端的同步脚本cwrsync.cmd默认内容如下

@ECHO OFF
REM *****************************************************************
REM
REM CWRSYNC.CMD - Batch file template to start your rsync command (s).
REM
REM By Tevfik K. (http://itefix.no)
REM *****************************************************************REM Make environment variable changes local to this batch file
SETLOCALREM ** CUSTOMIZE ** Specify where to find rsync and related files (C:\CWRSYNC)
SET CWRSYNCHOME=%PROGRAMFILES%\CWRSYNCREM Set HOME variable to your windows home directory. That makes sure
REM that ssh command creates known_hosts in a directory you have access.
SET HOME=%HOMEDRIVE%%HOMEPATH%REM Make cwRsync home as a part of system PATH to find required DLLs
SET CWOLDPATH=%PATH%
SET PATH=%CWRSYNCHOME%\BIN;%PATH%REM Windows paths may contain a colon (:) as a part of drive designation and
REM backslashes (example c:\, g:\). However, in rsync syntax, a colon in a
REM path means searching for a remote host. Solution: use absolute path 'a la unix',
REM replace backslashes (\) with slashes (/) and put -/cygdrive/- in front of the
REM drive letter:
REM
REM Example : C:\WORK\* --> /cygdrive/c/work/*
REM
REM Example 1 - rsync recursively to a unix server with an openssh server :
REM
REM       rsync -r /cygdrive/c/work/ remotehost:/home/user/work/
REM
REM Example 2 - Local rsync recursively
REM
REM       rsync -r /cygdrive/c/work/ /cygdrive/d/work/doc/
REM
REM Example 3 - rsync to an rsync server recursively :
REM    (Double colons?? YES!!)
REM
REM       rsync -r /cygdrive/c/doc/ remotehost::module/doc
REM
REM Rsync is a very powerful tool. Please look at documentation for other options.
REMREM ** CUSTOMIZE ** Enter your rsync command(s) here

针对前面的服务端配置,这里修改之后的内容如下

@echo off: 设置传入脚本的参数PARA1
SET PARA1=%1%
: 设置客户端程序的家目录
: set RSYNC_CLIENT_HOME=C:\Program Files (x86)\cwRsyncSET RSYNC_HOME=C:\cwRsync
: 设置客户端程序传输文件时使用的密码,对应于后面SERVER_FILE中的user。
SET PASS_FILE=/cygdrive/c/cwRsync/rsync20190126.pass: 设置日志文件路径
SET LOG_FILE=/cygdrive/c/cwRsync/rsync.log: 指定远端服务端所使用的端口
SET PORT=873: 指定远端服务中设定的用户,服务器IP,模块。格式必须是 username@IP::modulename
SET SERVER_FILE_PATH=user01@192.168.67.128::Repositories: 指定客户端本地对应的文件存放路径,注意这里的末尾需要带上正向斜线"/",代表这是个目录,:
: REM 当将本地文件CLIENT_FILE推送到远端时,没有斜线则代表推送该文件夹,有斜线则代表推送该文件夹下面的文件。:
: 例外,若是从远端拉取文件到本地时,这个斜线有无都没有关系。所以,我们最好都加上斜线,代表我们同步该文件夹下的所有文件。:
SET CLIENT_FILE_PATH=/cygdrive/d/backup/: 调用rsync程序执行文件同步,以下命令将%FILE1%同步到%FILE2%。
: %RSYNC_HOME%\bin\rsync -avzP   --delete-after --progress --password-file=%PASS_FILE% --log-file=%LOG_FILE% --port=%PORT%  %SERVER_FILE_PATH%  %CLIENT_FILE_PATH%if "%PARA1%"=="get"  ( echo  ====== starting %PARA1% files from %SERVER_FILE_PATH% .. ======%RSYNC_HOME%\bin\rsync -avzP   --delete-after --progress --password-file=%PASS_FILE% --log-file=%LOG_FILE% --port=%PORT%  %SERVER_FILE_PATH%  %CLIENT_FILE_PATH%echo  ====== successfully %PARA1% files !)
if "%PARA1%"=="pull" (echo  ====== starting %PARA1% files to %SERVER_FILE_PATH% .. ======%RSYNC_HOME%\bin\rsync -avzP   --delete-after --progress --password-file=%PASS_FILE% --log-file=%LOG_FILE% --port=%PORT%  %CLIENT_FILE_PATH%  %SERVER_FILE_PATH% echo  ====== successfully %PARA1% files !)pause

在cmd命令行中执行 cwrsync.cmd get 或者 cwrsync.cmd pull

设置windows计划任务

打开“任务计划程序”,选中“任务计划程序库”,点击右侧“创建任务”。

在“常规”标签下,输入名称,勾选“使用最高权限”,选择“Windows 10”。

保存成功后,可以在面板看到刚才创建的Rsync计划任务。

附录

rsync参数列表

rsync is a file transfer program capable of efficient remote update
via a fast differencing algorithm.Usage: rsync [OPTION]... SRC [SRC]... DESTor   rsync [OPTION]... SRC [SRC]... [USER@]HOST:DESTor   rsync [OPTION]... SRC [SRC]... [USER@]HOST::DESTor   rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DESTor   rsync [OPTION]... [USER@]HOST:SRC [DEST]or   rsync [OPTION]... [USER@]HOST::SRC [DEST]or   rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]The ':' usages connect via remote shell,
while '::' & 'rsync://' usages connect to an rsync daemon, and require SRC or DEST to start with a module name.frequently used:-a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)-r, --recursive             recurse into directories-l, --links                 copy symlinks as symlinks-p, --perms                 preserve permissions-t, --times                 preserve modification times-o, --owner                 preserve owner (super-user only)-g, --group                 preserve group-D                          same as --devices --specials--devices               preserve device files (super-user only)--specials              preserve special files-e, --rsh=COMMAND           specify the remote shell to use     -z, --compress              compress file data during the transfer--compress-level=NUM    explicitly set compression level--partial               keep partially transferred files     --bwlimit=KBPS          limit I/O bandwidth; KBytes per second-v, --verbose               increase verbosityless used:-q, --quiet                 suppress non-error messages--no-motd               suppress daemon-mode MOTD (see manpage caveat)-c, --checksum              skip based on checksum, not mod-time & size--no-OPTION             turn off an implied OPTION (e.g. --no-D)-R, --relative              use relative path names--no-implied-dirs       don't send implied dirs with --relative-b, --backup                make backups (see --suffix & --backup-dir)--backup-dir=DIR        make backups into hierarchy based in DIR--suffix=SUFFIX         set backup suffix (default ~ w/o --backup-dir)-u, --update                skip files that are newer on the receiver--inplace               update destination files in-place (SEE MAN PAGE)--append                append data onto shorter files--append-verify         like --append, but with old data in file checksum-d, --dirs                  transfer directories without recursing-L, --copy-links            transform symlink into referent file/dir--copy-unsafe-links     only "unsafe" symlinks are transformed--safe-links            ignore symlinks that point outside the source tree-k, --copy-dirlinks         transform symlink to a dir into referent dir-K, --keep-dirlinks         treat symlinked dir on receiver as dir-H, --hard-links            preserve hard links-E, --executability         preserve the file's executability--chmod=CHMOD           affect file and/or directory permissions-A, --acls                  preserve ACLs (implies --perms)-O, --omit-dir-times        omit directories from --times--super                 receiver attempts super-user activities-S, --sparse                handle sparse files efficiently-n, --dry-run               perform a trial run with no changes made-W, --whole-file            copy files whole (without delta-xfer algorithm)-x, --one-file-system       don't cross filesystem boundaries-B, --block-size=SIZE       force a fixed checksum block-size--rsync-path=PROGRAM    specify the rsync to run on the remote machine--existing              skip creating new files on receiver--ignore-existing       skip updating files that already exist on receiver--remove-source-files   sender removes synchronized files (non-dirs)--del                   an alias for --delete-during--delete                delete extraneous files from destination dirs--delete-before         receiver deletes before transfer, not during--delete-during         receiver deletes during transfer (default)--delete-delay          find deletions during, delete after--delete-after          receiver deletes after transfer, not during--delete-excluded       also delete excluded files from destination dirs--ignore-errors         delete even if there are I/O errors--force                 force deletion of directories even if not empty--max-delete=NUM        don't delete more than NUM files--max-size=SIZE         don't transfer any file larger than SIZE--min-size=SIZE         don't transfer any file smaller than SIZE--partial-dir=DIR       put a partially transferred file into DIR--delay-updates         put all updated files into place at transfer's end-m, --prune-empty-dirs      prune empty directory chains from the file-list--numeric-ids           don't map uid/gid values by user/group name--timeout=SECONDS       set I/O timeout in seconds--contimeout=SECONDS    set daemon connection timeout in seconds-I, --ignore-times          don't skip files that match in size and mod-time--size-only             skip files that match in size--modify-window=NUM     compare mod-times with reduced accuracy-T, --temp-dir=DIR          create temporary files in directory DIR-y, --fuzzy                 find similar file for basis if no dest file--compare-dest=DIR      also compare destination files relative to DIR--copy-dest=DIR         ... and include copies of unchanged files--link-dest=DIR         hardlink to files in DIR when unchanged--skip-compress=LIST    skip compressing files with a suffix in LIST-C, --cvs-exclude           auto-ignore files the same way CVS does-f, --filter=RULE           add a file-filtering RULE-F                          same as --filter='dir-merge /.rsync-filter'repeated: --filter='- .rsync-filter'--exclude=PATTERN       exclude files matching PATTERN--exclude-from=FILE     read exclude patterns from FILE--include=PATTERN       don't exclude files matching PATTERN--include-from=FILE     read include patterns from FILE--files-from=FILE       read list of source-file names from FILE-0, --from0                 all *-from/filter files are delimited by 0s-s, --protect-args          no space-splitting; only wildcard special-chars--address=ADDRESS       bind address for outgoing socket to daemon--port=PORT             specify double-colon alternate port number--sockopts=OPTIONS      specify custom TCP options--blocking-io           use blocking I/O for the remote shell--stats                 give some file-transfer stats-8, --8-bit-output          leave high-bit chars unescaped in output-h, --human-readable        output numbers in a human-readable format--progress              show progress during transfer-P                          same as --partial --progress-i, --itemize-changes       output a change-summary for all updates--out-format=FORMAT     output updates using the specified FORMAT--log-file=FILE         log what we're doing to the specified FILE--log-file-format=FMT   log updates using the specified FMT--password-file=FILE    read daemon-access password from FILE--list-only             list the files instead of copying them--stop-at=y-m-dTh:m     Stop rsync at year-month-dayThour:minute--time-limit=MINS       Stop rsync after MINS minutes have elapsed--write-batch=FILE      write a batched update to FILE--only-write-batch=FILE like --write-batch but w/o updating destination--read-batch=FILE       read a batched update from FILE--protocol=NUM          force an older protocol version to be used--iconv=CONVERT_SPEC    request charset conversion of filenames--tr=BAD/GOOD           transliterate filenames-4, --ipv4                  prefer IPv4-6, --ipv6                  prefer IPv6--version               print version number
(-h) --help                  show this help (-h works with no other options)

cwRsync-windows下的rsync工具相关推荐

  1. Windows 下连接mysql工具NavicatForMysql

    Windows 下连接mysql工具NavicatForMysql 一.软件介绍 Navicat for MySQL是一款强大的 MySQL 数据库管理和开发工具,它为专业开发者提供了一套强大的足够尖 ...

  2. windows下的linux工具,Windows下的Unix/Linux工具集:UnxUtils

    最近用dos命令多了些,感觉方便得多,对付一些老机器特别有效~只是可惜dos命令功效有限,如果能使用到linux系统上类似grep,sed,cat这样命令就完美了~ 果然和想得差不多,网上还真有&qu ...

  3. 测试工具:Windows下超强日志工具BareTail

    最近写了一些测试工具,经常希望能动态的查看日志文件,试了好些文本编辑文件如Emeditor.Vim等,一直没找到合适. 我希望支持的功能有: 支持大文件读取,速度要快 自动加载新的内容,直接定位到最后 ...

  4. windows下apk查看工具的原理

    游戏出了版本之后,提供给渠道,有部分渠道会修改包名(当他们内部系统做出调整后,可能会改包名),这个时候我又需要知道包名.之前没办法,试图反编译apk,发现失败了.然后就安装apk到手机上,手机上再下载 ...

  5. Windows下自动同步工具SyncToy的使用与定时执行部署

    最近因为需要用到一个自动同步两台虚拟机的工具,在网上找了许多资料,刚开始是觉得GoodSync这个不错,界面美观,功能完善易用,可定时执行等,但是这款软件是收费的,而且winserver下要使用企业版 ...

  6. Windows下UI自动化工具Inspect

    windows系统下的UI自动化工具Inspect是包含在WindowsSDK包里的,所以需要先下载SDK包,然后在SDK包路径下找到Inspect工具并打开使用就可以了. 官网下载链接:https: ...

  7. 2个 windows 下的网络测试工具

    环境 windows 10 64bit tcping tcproute 简介 TCPing 和 TCProute 都是 windows 下的用于测试 TCP 连接的工具,它们可以帮助用户确定网络连接的 ...

  8. Windows下代码比较工具Meld diff 以及 VScode配置,解决“Meld Diff Error: Error running diff command! StdErr: ‘meld‘ �

    最近在魔改代码,发现了新工具,避免了一句一句肉眼比较两份代码 首先在VScode 安装Meld Diff插件 插件安装完之后 运行 ctrl+shift+p,输入meld,会出现命令 第一个是比较已经 ...

  9. Windows下的IPMI工具

    说明 本文使用的Windows版本是10.0.18363版本,下载到的ipmiutil的版本是3.1.7.由于没有设备可以测试,目前的使用还存在问题,原因不明. IPMI工具下载 Windows下可用 ...

  10. Windows下使用pip工具安装第三方库报C++错误的解决方案

    前言 在 Windows 下安装 Python 进行开发,经常会使用 pip 或 pip3 工具来安装各种第三方库,随着使用的深入,大概率会遇到 "error: Microsoft Visu ...

最新文章

  1. GitLab 完成 1 亿美元融资 以 10 亿美元的估值成为“独角兽”
  2. boost::graph模块实现bfs算法的测试程序
  3. 【高清】鲁邦三世主题曲 - ルパン三世のテーマ'80 南澤大介 改编+演奏
  4. MySQL中的+作用,进行字符串的拼接用concat
  5. php求完数,php算法:求完全数 | 学步园
  6. Linux系统编程(五)时序竞态
  7. 浅谈ASP.NET框架
  8. 防止IE不支持console.log报错
  9. SpringBoot实战(九)之Validator
  10. hibernate 状态间转换及update,saveOrUpdte
  11. WEBPACK+ES6+REACT入门(3/7)-react组件以及props
  12. 【GISer必备】150+地图数据免费下载
  13. undertale人物_传说之下全人物介绍 人物评价解析
  14. 学号在java是什么意思_在JAVA程序中增加姓名学号
  15. 手机屏幕画面实时直播
  16. sqoop导入数据到hive
  17. JS的正则表达式及详解
  18. 蠕虫和从传统计算机病毒的区别主要体现在,蠕虫和传统计算机病毒的区别 病毒蠕虫和特洛伊木马...
  19. 联通宽带在停电以后断网,重启猫还是没网,可能是设置出问题了
  20. 专访图麟科技联合创始人张勋:AI商用化时代,图麟科技率先抢占工业赛道

热门文章

  1. 入侵服务器的一种方法
  2. 计算机电源触,笔记本电源接触不良会怎样【图文教程】
  3. UE4 HTC VIVE手柄按键对应Montion Controller 蓝图的命令
  4. 【题解】#10246. 「一本通 6.7 练习 3」取石子
  5. 写论文修改word标题的编号1/1.1/1.1.1/1.1.1.1
  6. 安装dataX的问题,com.alibaba.datax.common.exception.DataXException: Code:[Common-00], Describe
  7. 领域驱动架构(DDD)建模中的模型到底是什么?
  8. 加快黑群晖套件中心的套件下载速度
  9. buuctf web wp
  10. Excel如何按照颜色排序