1. Cwrsync Introduction
Cwrsync is the implementation version of Rsync on Windows, and rsync can transfer only modified files over the network by using the file transfer technology of the specific algorithm.
Cwrsync is primarily used for remote file synchronization backup and synchronization on Windows, which contains the Cygwin dll and the rsync two parts of the applicable Cygwin version.
Cwrsync is divided into server and Client, the version used in this article is 4.1.0, as follows:
CwrsyncServer V4.1.0:HTTP://PAN.BAIDU.COM/S/1EQPAIVW
Cwrsync V4.1.0:HTTP://PAN.BAIDU.COM/S/1PJ3B1FX
The following are examples of server and client-side configuration use, the following environment:
server:127.0.0.1
client:127.0.0.1
2. Server installation using 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\):
1Use chroot =false2Strict modes =false3Hosts allow = *4Log file =Rsyncd.log5PID file =Rsyncd.pid6Port =8737UID =08GID =09 Ten # Module Definitions One# Remember Cygwin naming conventions:c:\work becomes/cygwin/c/ Work A # - [Test] -Path =/cygdrive/d/Test theRead Only =false -Transfer logging = yes
View Code
Some important parameters are explained as follows:
1Use chroot =false2Strict modes =false3Hosts allow = *#允许所有IP访问4Log file =Rsyncd.log #日志文件5PID file =rsyncd.pid #进程文件6Port =873#服务端口号7UID =0#不限定用户8GID =0#不限定组9 Ten # Module Definitions One# Remember Cygwin naming conventions:c:\work becomes/cygwin/c/ Work A # - [Test] #认证的模块名, the client side needs to specify the use -Path =/cygdrive/d/test #需要做镜像同步的目录, such as d:/Test theRead Only =false -Transfer logging = yes
View Code
Note :
1. Uid=0 and gid=0 need to be specified, or the subsequent client synchronization will be error:
@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, you can refer to the Help file: C:\Program files\icw\doc\rsyncd.conf.html
2.3 Starting the Service
Run Services.msc on the server machine, select the service "Rsyncserver" To configure the startup type to "Automatic" and start the service.
3. Client installation using 3.1 installation
Same as server, click Next and install with the default configuration.
3.2 Use
Create a new Test.bat file with the following contents:
@echo off Set Rsync_home=%rsync_home%rsync-avzrp--progress--delete rsync://127.0.0.1:873/test/cygdrive/e/test
Detailed command parameters:
-AVZP -a parameter, equivalent to-rlptgod:-R is recursive -L is a link file, meaning copy link file -p means keep file original permission -t Keep the file in its original time -g Keep The file original user group-o keep the file original owner-D equivalent to block device file -v verbose mode output -z transfer compression - P shows the transfer progress --progress shows the backup synchronization process --deletedeletes files in the client that are not in the server, that is, if the server deletes the file, Then the client also deletes the file accordingly, maintaining a true consistent rsync://127.0.0.1:873/test configuration Sever IP address and module name that needs to be synchronized (configured in Server rsyncd.conf)/cygdrive/e /test the client local directory where the synchronization files are stored e:\test
Running test.bat,client will synchronize the files remotely, as follows:
4.Windows The Rsync service cannot start a workaround
After the server unexpectedly restarts, the Rsyncserver service cannot start, prompting "the Reyncserver service on the local computer has started and stopped." The method is to remove or rename the Rsyncd.pid file under the installation directory, and then restart the Rsyncserver service, OK, the Rsyncd.pid file will be regenerated automatically.
How to use 5.rsync exclusion directories
requirement Scenario: currently want to synchronize a folder above a server to 5 client, but do not want to synchronize all the files, the individual files do not need to synchronize, so you must add the files in the server's configuration file to exclude synchronization, This requires the use of the exclude parameter. This can be used on the client, or directly on the server configuration. The following example is configured on the server's rsyncd.conf file.
Case: Config file directory has test1, test2 and test3 These three directories, all of these three directories have a test.txt file. The following are different configuration information to achieve different synchronization requirements.
Envision--config--test1--test.txt
|| ——— Test2--test.txt
|| ——— Test3--test.txt
5.1 Exceptions to the Test1 directory through the Exclude keyword
=/cygdrive/d/envision/ from == test1/false= Yes Lock file = Rsyncd. Lock
5.2 Exceptions to the Test2 and TEST3 directories with the Exclude from keyword
=/cygdrive/d/envision/ from == test1/false= Yes Lock file = Rsyncd. Lock
Where the Rsync.excluede file is in the same directory as rsyncd.conf, where the file content is, where "/" is very important.
test2/test3/
5.3 The specified file under Exclude directory
Exclude and exclude from are not only restricted to directories, but also to the specified file names.
Add a file test2.txt under the Test1 directory and configure it as follows
=/cygdrive/d/envision/ from == test1/false= Yes Lock file = Rsyncd. Lock
Reprint: http://lovesoo.org/windows-remote-data-synchronization-tool-cwrsync.html
Windows Remote Data Sync tool Cwrsync