The CentOS Rsync server implements the data synchronization configuration method with the Windows cwRsync client

  • 2020-05-14 05:28:07
  • OfStack

Description:
1. Rsync server
System: CentOS 5.5
IP address: 192.168.21.160
Data storage directory: /data/osyunwei
2. cwRsync client
System: Windows Server 2003
IP address: 192.168.21.130
Synchronized directory: D:\osyunwei
Objectives:
The cwRsync client automatically synchronizes data from the Rsync server /data/osyunwei directory to the D:\osyunwei directory at 3:00 a.m. every day

1. Rsync server configuration

1. Turn off SELINUX
vi /etc/selinux/config # edit firewall configuration files
#SELINUX=enforcing # comment out
#SELINUXTYPE=targeted # comment out
SELINUX = disabled # increase
:wq # save, close
shutdown-r now # restart the system


2. Enable firewall tcp 873 port (Rsync default port)
vi /etc/sysconfig/iptables # edit the firewall configuration file
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 873 -j ACCEPT
: wq! # save
/ etc/init d/iptables restart # last restart the firewall configuration to take effect
3. Install Rsync server software
yum install rsync xinetd # installation
vi/etc/xinetd d/rsync # edit configuration files, set rsync powered up
disable = no # changed to
/ etc/init d/xinetd start # start (CentOS is xinetd to manage Rsync service)
4. Create the rsyncd.conf configuration file
vi /etc/ rsyncd.conf # to create the profile, add the following code
log file = / var log/rsyncd log # log file location, start rsync automatically generated after the file, without having to create in advance.
[osyunwei] # custom name
path = /data/osyunwei #Rsync server data directory path
comment = osyunwei # module name is the same as the [osyunwei] custom name
uid = root # set rsync to root
gid = root # set rsync to root
port=873 # default port
read only = no # set to no, cwRsync client can upload files,yes read only
write only = no # is set to no. cwRsync client can download files,yes cannot
auth users = osyunweibakuser # to perform data synchronization. You can set multiple usernames, separated by commas in English
secrets file = /etc/ rsync.pass # user authentication profile, which holds the user name and password, will be created later
hosts allow = 192.168.21.130 # allows the client IP address for data synchronization. Multiple addresses can be set, separated by commas in English
hosts deny = 192.168.21.254 # the client IP address where data synchronization is disabled can be set to multiple, separated by commas in English
list = yes # displays a list of Rsync server resources

: wq! # save

5. Create user authentication files
To the vi /etc/ rsync.pass # profile, add the following
osyunweibakuser:123456 # format, username: password, you can set more than one, 1 username: password per line
: wq! # save
6. Set file permissions
chmod 600 /etc/ rsyncd.conf # sets read and write permissions for the file owner
chmod 600 /etc/ rsync.pass # sets read and write permissions for the file owner
7. Start rsync
/ etc/init d/xinetd start # start
service xinetd stop # stop
service xinetd restart # reboot

2. cwRsync client Settings

1. Download cwRsync client software
Download address: http: / / s ofstack. com
2. Install cwRsync client
Unzip cwRsync_4.0.3 _Installer.zip double-click to open cwRsync_4.0.3 _Installer.exe
Next next step 1
IAgree agrees to install
Next
The default installation path is C:\Program Files\cwRsync
Install installation
Close installation complete, close
3. Test whether the communication with Rsync server is successful
start-run-cmd
Enter cd C:\Program Files\cwRsync\bin enter
Enter telnet 192.168.21.160873
The telnet interface appears, indicating that the communication with the Rsync server was successful
Note C:\Program Files\cwRsync\bin means the cwRsync program installation path
4. cwRsync client synchronizes data of Rsync server
Start - run -cmd, enter cd C:\Program Files\cwRsync\bin enter
Input again
rsync --port=873 -vzrtopg --progress --delete osyunweibakuser@192.168.21.160::osyunwei /cygdrive/d/osyunwei
Enter password: 123456 enter
To start synchronizing data and wait for execution to complete, you can open D:\osyunwei and Rsync server /data/osyunwei directory and compare them 1 to see if they are the same
Description:
d/osyunwei representative D: \ osyunwei
osyunwei stands for the custom module name comment = osyunwei in the /etc/ rsyncd.conf file
192.168.21.160 #Rsync server IP address
osyunweibakuser # user who performs data synchronization
- port = 873 # port
-vzrtopg --progress # shows details of the synchronization process
--delete # removes data from the cwRsync client D:\osyunwei directory that is different from the Rsync server /data/osyunwei directory

3. Add batch script files to the task plan of cwRsync client, and automatically synchronize the data in Rsync server /data/osyunwei directory to D:\osyunwei directory at 3:00 am every day

1. Open C:\Program Files\cwRsync\bin and create a new passwd.txt
Enter 123456
save
Continue to create osyunwei.bat in C:\Program Files\cwRsync\bin
The input
@echo off
echo.
echo starts to synchronize data, please wait a moment...
echo.
cd C:\Program Files\cwRsync\bin
rsync -vzrtopg --port=873 --progress --delete osyunweibakuser@192.168.21.160::osyunwei /cygdrive/d/osyunwei < passwd.txt
echo.
echo data synchronization completed
echo.
Last save exit

2. Add batch script to Windows task plan


Start - setup - control panel - task plan
Open the add task plan, next step
Browse and select osyunwei.bat in C:\Program Files\cwRsync\bin
Perform this task, select each day, and take the next step
Starting time: 3:00
Run this task: each day, step 1
Enter the login password for the Windows system administrator, next step
complete
Extension: to adjust the timing of synchronization, open osyunwei in the task plan
Switch to scheduling for option Settings, or turn on advanced to run the osyunwei.bat script once every few minutes

At this point, the CentOS Rsync server and Windows cwRsync client achieve data synchronization


Related articles: