Use cwRsync to implement timed synchronization and backup of server files in windows (with error handling methods)

Source: Internet
Author: User

Download the cwRsync server and client software as follows:

Server: cwRsync Server (multiple Server File Sync Servers) V4.1.0 free version

Client: cwRsync (Multi-Server File sync client) V4.1.0 free version

However, we generally do not use the latest version. For earlier versions, you can download them from the Server File sync area of s.jb51.net.

Then I installed the server (10.0.2.136) on the local machine, and then installed the client on another machine (10.0.2.20.) in the same network segment. For testing, I put the dnt site file of our product on the drive F on the local machine, at the same time, you are ready to use the aspx and config folders in the site folder as the folders for Synchronizing files. Enter the following content in the rsyncd. config file of the server:Copy codeThe Code is as follows: use chroot = false
Strict modes = false
Hosts allow = *
Log file = rsyncd. log
Pid file = rsyncd. pid
Port = 52326
Max connections = 4

# Module definitions
# Remember cygwin naming conventions: c: \ work becomes/cygwin/c/work
#
[T_aspx]
Path =/cygdrive/f/dnt_snap/aspx
Read only = false
Transfer logging = yes
Lock file = rsyncd. lock

[T_config]
Path =/cygdrive/f/dnt_snap/config
Read only = false
Transfer logging = yes
Lock file = rsyncd. lock

Note: In the above content, set the listening port to 52326.
In this way, on the control panel --> management tools --> service, locate the service and start it, such:

In this case, we can create a folder named sync on the F disk of the client (10.0.2.20, at the same time, create two folders named "config" and "aspx" respectively below to synchronize the folders on the server.

Then create a batch file named dnt_rsync.bat with the following content:Copy codeThe Code is as follows: rsync-av rsync: // 10.0.2.136: 52326/t_config/cygdrive/f/sync/config
Rsync-av rsync: // 10.0.2.136: 52326/t_aspx/cygdrive/f/sync/aspx

And put it in the bin directory under the cwRsync Client installation directory (my installation directory is as follows: C: \ Program Files \ cwRsync \ bin), and then double-click to start it.
In this way, the file will be synchronized:

Then, we can view the synchronized files in the corresponding current file drive of the client.

Of course, cwRsync uses incremental and modified Synchronization Methods. If you modify the corresponding files on the server, only modified files or new files will be synchronized during synchronization.

The following describes how to create a scheduled task and execute a scheduled synchronization task through the "Task Plan" in windows.

First, click "Control Panel"> "Task Plan"> "add Task Plan" on the client's machine, and click "Next" in the corresponding pop-up window, click "Browse" in the navigation window, as shown below, and select the previously created batch file "dnt_sync.bat ":

At this time, the system will display the following window prompts the execution method of the current scheduled task. Here I select to execute the task every day (once ):

Here, the system will create a task plan named dnt_sync, and prompt the start time of the task in the following window:

Do not make any changes here. Click next, and then perform identity authentication (usually the Administrator). The task is scheduled to run smoothly. You must have sufficient permissions to complete the task :)

Click Finish to create a task plan. However, it is executed by day. What should we do if we want it to be executed once every minute? In fact, it is very simple. Just click the newly created task plan with the mouse, select "properties" in the pop-up menu. In the displayed window, click "advanced" in "Schedule", as shown below:

In this case, a subwindow named "advanced plan options" is displayed, and the following settings are made for others:

By now, this scheduled task will run every minute 24 hours a day to synchronize the previous two folders.

Recently, software was used more time than software development time. As a result, the amount of code developed is not as large as before. However, this type of software is still very useful in application scenarios and may be used in the future. Therefore, I will share this article with you and use it as a "backup.

Author: daizhj, Dai zhenjun

Many details are not taken into account in the above article. Many problems often occur in practical applications.

CwRsync synchronization FAQ:
Error 1:
@ ERROR: auth failed on module xxxxx
Rsync: connection unexpectedly closed (90 bytes read so far)
Rsync error: error in rsync protocol data stream (code 12) at I/O. c (150)
Solution: this is because the password is set incorrectly and cannot be successfully logged in. Check rsync. pwd to see if the customer service matches. This also happens when the rsync service is not started on the server.
Error 2:
Password file must not be other-accessible
Continuing without password file
Password:
Solution: this is because the rsyncd. secrets permission is incorrect, or the storage location is not NTFS partition.
Error 3:
@ ERROR: chroot failed
Rsync: connection unexpectedly closed (75 bytes read so far)
Rsync error: error in rsync protocol data stream (code 12) at I/O. c (150)
Solution: Because the path you set in rsync. conf does not exist, you must create a new directory to enable synchronization.
Error 4:
Rsync: failed to connect to 192.168.0.10: No route to host (113)
Rsync error: error in socket IO (code 10) at clientserver. c (104) [handler ER = 2.6.9]
Solution: it is possible that the other party does not start the instance, the firewall blocks the instance, or the firewall blocks the instance on the network. To disable the firewall, open the tcp udp port (873 by default.
Error 5: Password Problems
If secrets file = wtjb51.conf is included in the configuration, you need to create a wtjb51.conf file and open it in Notepad. Enter the username and password to facilitate the client to pass the password.
Rsyncd. conf

Copy codeThe Code is as follows: use chroot = false
Strict modes = false
Hosts allow = *
Log file = rsyncd. log
Pid file = rsyncd. pid

# Module definitions
# Remember cygwin naming conventions: c: \ work becomes/cygwin/c/work
#
[Wtjb51]
Path =/cygdrive/d/jb51net
Read only = false
Transfer logging = yes
Auto user = wtjb51
Secrets file = wtjb51.conf

Wtjb51.confCopy codeThe Code is as follows: wtjb51: www.jb51.net

Error 6: A permission error is prompted.
The server needs to write and modify permissions to the directory svcwrsync user.
If you have other problems, contact us. Qq: 461478385

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.