1. Cwrsync Introduction
Cwrsync is an implementation version of Rsync on Windows, and rsync can transfer only modified files over the network by using file transfer technology for specific algorithms.
Cwrsync is primarily used for remote file synchronization backups and synchronizations on Windows, which contains both Cygwin DLLs and the Cygwin version of Rsync.
Cwrsync is divided into server and client, the version used in this article is 4.1.0 and the download address is as follows:
Cwrsyncserver V4.1.0:HTTP://PAN.BAIDU.COM/S/1EQPAIVW
Cwrsync V4.1.0:HTTP://PAN.BAIDU.COM/S/1PJ3B1FX
Or go to s.jb51.net to download
The following is an example of server and client-side configuration usage, and this article uses the following environment:
server:192.168.85.236
client:192.168.85.249
2. Server installation Use
2.1 Installation
Click Next and install with the default configuration.
2.2 Configuration
Modify the configuration file rsyncd.conf as follows (default location: C:\Program files\icw\):
Use chroot = False
Strict modes = False
hosts allow = *
log file = Rsyncd.log
pid file = rsyncd.pid
po RT = 873
uid = 0
gid = 0
# Module Definitions
# Remember Cygwin naming conventions:c:\work Becomes/cy Gwin/c/work
#
[Test]
path =/cygdrive/d/test
Read Only = False
transfer logging = yes
Some important parameters are explained as follows:
Use Chroot = False
Strict modes = False
Hosts allow = * #允许所有IP访问
Log file = Rsyncd.log #日志文件
PID file = Rsyncd.pid #进程文件
Port = 873 #服务端口号
UID = 0 #不限定用户
GID = 0 #不限定组
# Module Definitions
# Remember Cygwin naming conventions:c:\work becomes/cygwin/c/work
#
[Test] #认证的模块名, the client side needs to specify the use of the
Path =/cygdrive/d/test #需要做镜像同步的目录, such as D:/test
Read Only = False
Transfer logging = yes
Note:
1. Uid=0 and gid=0 need to be specified, otherwise the client will make an error when synchronizing:
@ERROR: Invalid UID Nobody
Rsync Error:error starting Client-server Protocol (code 5) at MAIN.C (1516) [receiver=3.0.8]
2. The above is just a simple configuration example, there are many other options to refer to the Help file: C:\Program files\icw\doc\rsyncd.conf.html
2.3 Start Service
Run Services.msc on the server machine, select the service "rsyncserver" Configuration Startup type is "Automatic", and then start the service.
3. Client Installation Use
3.1 Installation
Same as server, click Next, and install with the default configuration.
3.2 Use
Create a new Test.bat file that reads as follows:
@echo off
set Rsync_home=c:\program files\cwrsync\bin
cd%rsync_home%
C:
rsync-avzp--progress-- Delete Rsync://192.168.85.236:873/test/cygdrive/d/test
Detailed command parameters:
-AVZP-a
parameter, which is equivalent to-rlptgod:-
R is recursive
-L is a linked file, meaning copy-link file-p means to keep the file original permission-T to keep the file original-
G to maintain the
original user group C12/>-o Keep the original owner-
D equivalent to the block device file-
v Verbose mode output-
Z Transport time Compression-
p display transfer Progress
--progress Show backup synchronization process
--delete Delete files in the client that are not in the server, that is, if the server deletes this file, then the client also deletes the file accordingly, keeping the true consistency
rsync://192.168.85.236:873/test Configure the IP address of the sever and the module name that needs to be synchronized (configured in Server rsyncd.conf)
/cygdrive/d/test the client local directory where the synchronization files are stored D:\test
Run Bat,client will file remote synchronization, screenshot as follows:
3.3 Test
In the above environment, a large number of file synchronization tests, the results are as follows:
1. Each time a synchronization is made, the client obtains a list of updated files, which takes longer (5min47s)
2 when the number of files is larger (2.7w 27.5G). On this basis, incremental updates take a short time, and updating 100 files (minus get-list times) is only time-consuming and 16s
4. Schedule Task configuration
1. Select on client machine: Control Panel-> Task Schedule-> Add Task Schedule
2. Click Next-> Browse, open the Test.bat file above
3. Select Execute once a day
4. Configure Start time
5. Click Next, enter the server username and password, complete the task add
6. Select the task you just added, configure properties: daily schedule-> Advanced, select Duplicate , the configuration is performed every 20 minutes, and lasts 24 hours
At this point, the scheduled task is automatically synchronized between the client and the server in the same way that it runs every 20 minutes, 24 hours a day.