[Reprint] cwRysncServer Windows way to synchronize files like Linux

https://www.osyunwei.com/archives/4788.html

 

1, cwRsyncServer server

System: Windows Server 2003

IP Address: 192.168.21.134

Data storage directory: D: \ osyunwei

2, Rsync client

System: CentOS 6.3

IP Address: 192.168.21.132

Synchronize directory: / osyunwei

achieved goals:

Rsync client at 3:00 am every day automatically synchronize cwRsyncServer server D: \ directory to the number osyunwei / osyunwei directory

A, cwRsyncServer server configuration

annex:

cwRsyncServer Download:

http://jaist.dl.sourceforge.net/project/sereds/cwRsync/4.0.3/cwRsyncServer_4.0.3_Installer.zip

Decompression cwRsyncServer_4.0.3_Installer.zip, double-click cwRsyncServer_4.0.3_Installer.exe

System operation and maintenance www.osyunwei.com Reminder: qihang01 original content © All rights reserved Please indicate the source and description link

Next

I Agre (agree)

The installation path, you can default

Next

Service account: SvcCWRSYNC (a new system account)

Type password: password

Confirm password: password

Note: The system will automatically create an account: SvcCWRSYNC to run the server program cwRsyncServer

The above information can be default

Install (Installation)

Close (off), the installation is complete

Start - Settings - Control Panel - Administrative Tools - Services

Find RsyncSever option, double-click to open

Startup Type: Automatic

Point "Start"

- - - OK

打开D盘,右键单击osyunwei文件夹,选择属性,切换到安全选项,点添加

输入:SvcCWRSYNC

确定

允许所有权限

应用,确定

系统运维 www.osyunwei.com 温馨提醒:qihang01原创内容©版权所有,转载请注明出处及原文链接

打开C:\Program Files\ICW目录

用记事本打开rsyncd.conf,修改添加以下内容(修改之前先备份文件为rsyncd.confbak)

use chroot = false

strict modes = false

hosts allow = *

log file = rsyncd.log

# Module definitions

# Remember cygwin naming conventions : c:\work becomes /cygwin/c/work

#

#[test]

#path = /cygdrive/c/work

#read only = false

#transfer logging = yes

[osyunwei]

path = /cygdrive/d/osyunwei

read only = true #客户端只读

list = no  #不允许列出文件

hosts allow=192.168.21.132  #允许连接IP,多个IP中间用英文状态下逗号隔,不限制IP填写 *即可

auth users =osyunwei  #允许连接的用户名

secrets file = etc/rsyncd.secrets  #存放用户名密码的认证文件路径

修好完成之后,保存退出

在C:\Program Files\ICW\etc目录下面新建rsyncd.secrets文件

用记事本打开,输入以下内容

osyunwei:123456    #用户名:密码

最后保存退出

cwRsyncServer服务端安装设置完成

二、Rsync客户端配置

1、关闭SELINUX

vi /etc/selinux/config

#SELINUX=enforcing #注释掉

#SELINUXTYPE=targeted #注释掉

SELINUX=disabled #增加

:wq #保存,退出

shutdown -r now #重启系统

2、开启防火墙tcp 873端口(Rsync默认端口,Rsync作为客户端是不需要开启防火墙端口的,这里开启,方便以后扩展作为服务端)

vi /etc/sysconfig/iptables #编辑防火墙配置文件

-A INPUT -m state --state NEW -m tcp -p tcp --dport 873 -j ACCEPT

:wq! #保存,退出

/etc/init.d/iptables restart #最后重启防火墙使配置生效

3、安装Rsync客户端软件

yum install rsync xinetd   #安装,如下图所示,输入y安装

vi /etc/xinetd.d/rsync  #编辑配置文件,设置开机启动rsync

把disable = yes 修改为

disable = no

:wq! #保存,退出

/etc/init.d/xinetd start  #启动(CentOS中,Rsync是以xinetd来管理的)

4、测试Rsync客户端是否与cwRsyncServer服务端通信成功(cwRsyncServer服务端防火墙需要开启tcp 873端口)

yum install telnet   #安装telnet测试工具

telnet 192.168.21.134 873  #输入命令后回车,如下图所示,表示通信成功

Rsync客户端安装设置完成

三、设置Rsync客户端与cwRsyncServer服务端同步数据(以下操作在Rsync客户端进行)

1、测试数据同步

在终端命令行输入

rsync -vzrtopg --port=873 --progress --delete [email protected]::osyunwei /osyunwei

提示输入密码:123456  

注意:此处的密码为cwRsyncServer服务端C:\Program Files\ICW\etc\rsyncd.secrets文件配置的密码

回车之后,图下图所示,表示数据同步成功

系统运维 www.osyunwei.com 温馨提醒:qihang01原创内容©版权所有,转载请注明出处及原文链接

cd  /osyunwei  #进入数据同步目录

ls  #显示文件信息

可以看到数据已经存在了

2、添加计划任务,每天自动执行数据同步脚本

vi  /etc/passwd.txt    #配置文件,添加以下内容

123456  #密码

:wq!  #保存退出

chmod 600 /etc/passwd.txt   #设置文件权限,只设置文件所有者具有读取、写入权限即可

cd /home

vi  osyunweibak.sh   #编辑,添加以下内容

#!/bin/sh

rsync -vzrtopg --port=873 --progress --delete [email protected]::osyunwei /osyunwei --password-file=/etc/passwd.txt

:wq!   #保存,退出

chmod +x /home/osyunweibak.sh  #添加脚本直接权限

yum install vixie-cron  #安装计划任务,某些系统上可能没有预装

vi  /etc/crontab   #编辑,在最后添加以下内容

0 3 * * * root /home/osyunweibak.sh     表示每天凌晨3点执行备份 

:wq!  #保存,退出  

chkconfig crond on #设为开机启动

service crond start #启动

/etc/rc.d/init.d/crond restart  #重启

设置完成之后,

每天凌晨3点,Rsync客户端会自动同步cwRsyncServer服务端D:\osyunwei目录数据到自己的/osyunwei目录中

至此,CentOS 6.3 Rsync客户端与Windows Server 2003 cwRsyncServer服务端实现数据同步设设置完成

Guess you like

Origin www.cnblogs.com/jinanxiaolaohu/p/12356747.html