Use rsync to synchronize windows and linux Files

Source: Internet
Author: User
Tags connection reset

Windows as a file server, using rsync windows Service version: cwRsyncServer: http://rsync.samba.org

You must set the account and password used for system services during the installation process.
Note: This account is used to enable the crsync server service. You must assign the account the corresponding permissions on the files to be synchronized. Otherwise, the files to be synchronized cannot be operated.

After the installation is complete, modify the configuration file rsyncd. conf. The configuration file is as follows:Copy codeThe Code is as follows: port = 52326
Use chroot = false
Strict modes = false
# Hosts allow = * # allow all access
Hosts allow = 192.168.10.2 # specify a specific IP address to allow access
Log file = rsyncd. log
Lock file = rsyncd. lock
Max connections = 10
UID = 0
GID = 0
# Module definitions
# Remember cygwin naming conventions: c: \ work becomes/cygwin/c/work
#
[Test]
Path =/cygdrive/c/work
Read only = false
Transfer logging = no

[Test2]
Path =/cygdrive/d/wwwroot/yanghengfei_com
Read only = yes
Transfer logging = no
Auth users = coldstar # account used for synchronization
Secrets file = rsyncd. secrets # Password file

Note:
The format of the rsyncd. secrets configuration file is User name: Password, for example:
Coldstar: 123456

Coldstar is added with a password of 123456.

Run the following synchronization command on a Linux Server:

Rsync-vzrtopg -- progress -- delete rsync: // coldstar@192.168.10.1: 52326/test2/root/test2

Then enter the password at the password: prompt.

You can also write the password to the configuration file for reference, such:
Rsync-vzrtopg -- progress -- delete -- password-file =/etc/rsync. pass rsync: // coldstar@192.168.10.1: 52326/test2/www/users/yanghengfei_com

Write the preceding commands into a scheduled task and execute them every minute to achieve real-time synchronization.

Note:
In the preceding command line-In vzrtopg, v is verbose, z is compression, r is recursive, and topg is a parameter that maintains the original file attributes such as owner and time. -- Progress indicates that the detailed progress is displayed. -- delete indicates that if the server deletes the file, the client also deletes the file to ensure true consistency.

Appendix: FAQs about rsync:

Error 1: rsync: read error: Connection reset by peer (104)
Rsync error: error in rsync protocol data stream (code 12) at io. c (794) [runner ER = 3.0.2]
Solution: The rsync service is not enabled on the server. Enable the service. Or the port specified by the firewall is enabled and cannot be accessed.

ERROR 2: @ ERROR: chdir failed
Rsync error: error starting client-server protocol (code 5) at main. c (1495) [runner ER = 3.0.2]
Solution: the synchronization directory on the server has no permission. The default user of cwrsync is Svcwrsync. Add the user Svcwrsync permission to the synchronization directory.

ERROR 3: @ ERROR: failed to open lock file
Rsync error: error starting client-server protocol (code 5) at main. c (1495) [runner ER = 3.0.2]
Solution: Add lock file = rsyncd. lock to the server configuration file rsyncd. conf.

ERROR 4: @ ERROR: invalid uid nobody
Rsync error: error starting client-server protocol (code 5) at main. c (1506) [runner ER = 3.0.2]
Solution: Add the following two lines to the rsyncd. conf file to solve the problem.
UID = 0
GID = 0

ERROR 5: @ ERROR: auth failed on module test2
Rsync error: error starting client-server protocol (code 5) at main. c (1296) [runner ER = 3.0.2]
Solution: the server does not specify the correct secrets file. Add the following configuration lines in the [test2] configuration section:
Auth users = coldstar # account used for synchronization
Secrets file = rsyncd. secrets # Password file

Error 6: password file must not be other-accessible
Solution: The pass file on the client must have the permission of 600 and chmod 600/etc/rsync. pass.

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.