Synchronous backup of rsync from windows to Linux

Source: Internet
Author: User
Tags connection reset rsync
Name Role IP address
Windows Server 2003 Server Eth0: 192.168.1.1
Rhel5.5 Client Eth0: 192.168.1.2
Bytes
My computer-right-click Management-services and applications-services find rsyncsever, double-click to start
Provide desktop Interaction
 
Open the E disk and create the folder to be backed up. Right-click the Benet folder named Benet (this is a folder, not a file), select Properties, switch to the security option, and click Add input: svccwrsync
 
Open the c: \ Program Files \ ICW directory and use NotePad to open rsyncd. conf, modify and add the following content (back up before modification to prevent errors and re-change)
 
Edit rsyncd. CONF file use chroot = falsestrict modes = falsehosts allow = * log file = rsyncd. log # module definitions # Remember cygwin naming conventions: C: \ work becomes/cygwin/C/work #
[Benet] # backup template Path =/cygdrive/e/benetread only = true # client-only hosts allow = 192.168.1.2 # Allow IP addresses to be connected. Multiple IP addresses are separated by commas (,) in English, if you do not limit the IP address, enter * to auth users = Benet # the user name secrets file = ETC/rsyncd that can be connected. secrets # path of the authentication file for storing the user name and password
 
Open the/etc/rsyncd. Secrets file in the c: \ Program Files \ ICW directory in notepad and enter the username and password Benet: 123.
Ii. Configure the rsync client. 1. View The SELinux mechanism and disable SELinux [root @ localhost ~]. # Getenforcedisabled2: Enable TCP port 873 of the firewall so that you can use [root @ localhost ~] on the server later # Vi/etc/sysconfig/iptables # edit the firewall configuration file-A input-M State-State new-m tcp-p tcp-dport 873-J accept
3. Install the rsync client [root @ localhost ~] # Yum install rsync xinetd [root @ localhost ~] # Vi/etc/xinetd. d/rsync # edit the configuration file and set rsync to start upon startup. Rsync on centos will disable = yes when xinetd is enabled, change to noservice rsync {disable = No socket_type = stream wait = no user = root server =/usr/bin/rsync server_args = -- daemon log_on_failure + = userid}/etc/init. d/xinetd start # Start
4. Test the remote connection to test whether the communication works normally. Install Telnet [root @ localhost ~]. # Telnet 192.168.1.1 873 # successfully trying 192.168.1.1... connected to 192.168.1.1 (192.168.1.1). Escape Character is '^]'. @ rsyncd: 30.0
In order not to manually enter the password for data synchronization, we also create a password file on the client that is the same as that on the server (the file path and password must be the same as on the server, and the client does not need to write a name) [root @ localhost ~] # Echo "123">/etc/rsyncd. Secrets # The file names can be different, but you need to [root @ localhost ~] Under/etc # Cat/etc/rsyncd. secrets123 [root @ localhost ~] # Chmod 600/etc/rsyncd. Secrets
Note: The password here is the password configured in the C: \ Program Files \ ICW \ etc \ rsyncd. Secrets file of the cwrsyncserver server [root @ localhost ~] # Rsync-avz -- password-file =/etc/rsyncd. secrets benet@192.168.1.1: Benet/opt/sorting ing file list... done. /11.txt sent 91 bytes converted ed 192 bytes 51.45 Bytes/sectotal size is 52 speedup is 0.18
5. implement automatic data synchronization and manually write a small script. [Root @ localhost ~] template defined on the server after the colon # Vim rsync. Sh #! /Bin/bash/usr/bin/rsync-avz -- password-file =/etc/rsyncd. Secrets benet@192.168.1.1: Benet/OPT add automated backup [root @ localhost ~] # Chmod + x/root/rsync. Sh [root @ localhost ~] # Crontab-e *****/root/rsync. Sh
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.