Linux-Windows实现rsync
Linux为SERVER端,windows为 CLIENT端
Rsync 整 理 文 档
一.Server端的配置
1. 用的rsync的版本是rsync-2.6.8.tar.gz,可以到原始网站下载:http://rsync.samba.org/ftp/rsync/下载
2. 两台服务器的IP如下:
Client————192.168.5.9 (rsync的client端)
Server————192.168.5.210 (rsync的server端)
3. (1)rsync的server端的操作:
# tar -zxvf rsync-2.6.8.tar.gz
# cd rsync-2.6.8
# ./configure
# make
# make install
说明一点,客户机和服务器都要安装rsync。客户机以客户端方式运行rsync,服务器端以服务器方式运行rsync,它监听873端口
(2)# touch /etc/ rsyncd.conf
# vi /etc/ rsyncd.conf (内容如下)
#全局配置部分
read only = no
list = yes
uid = root
gid = root
hosts allow = *
#hosts allow = 192.168.5.9
#hosts deny = 10.4.5.0/24
use chroot = no
max connections = 10
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
#模块配置部分
[rsyncd]
comment = pag’s directory (自己的说明)
path = /home/test/software (要同步server端的目录)
auth users = rsync (用到的用户)
secrets file = /etc/rsyncd.secrets
(3)生成验证证文件
建立同步用户并设置密码
# useradd rsync
# passwd rsync
# echo “rsync:rsync” > /etc/rsyncd.secrets (rsync:rsync为用户和密码,格式为user:passwd)
# chown root:root /etc/rsyncd.secrets
# chmod 600 /etc/rsyncd.secrets
(4) 最后在server端将rsync以守护进程形式启动
命令为: rsync –daemon
rsync启动的端口为 873端口
最好用ntsysv或者chkconfig将rsync设置为开机自动启动
chkconfig –level 35 sync on
如果运行失败使用:
安装xinetd,并修改rsync相关配置
# yum -y install xinetd
# vi /etc/xinetd.d/rsync
如下代码:
# default: off
# description: The rsync server is a good addition to an ftp server, as it \
# allows crc checksumming etc.
service rsync
{
disable = yes
socket_type = stream
wait = no
user = root
server = /usr/local/bin/rsync
server_args = –daemon
log_on_failure += USERID
}
将disable = yes改成disable = no
然后重启xinetd
# /etc/init.d/xinetd restart
二.Client端的配置(windows)
1,安装cwRsync工具,http://fengyu.souidc.org/source/cwRsync_Client_2.0.10_Installer.zip
cwRsync_2.0.10_Installer.zip,安装
2. 写认证的密码文件例如在d:/rsync/rsyncd.secrets , 内容是上面的设置的密码:rsync ,建立要备份到本地的目录如: d:/rsync
3.在dos到它的bin目录下,D:\Program Files\cwRsync\bin
执行:
rsync -vzrtopg –progress –delete –password-file=/cygdrive/d/rsync/rsyncd.secrets /cygdrive/d/rsync
4.可以写个rsync_test.bat批处理文件:
@ECHO OFF
d:
cd “Program Files\cwRsync\bin”
chmod 600 rsync.secrets
rsync -vzrtopg –progress –delete –password-file=/cygdrive/d/rsync/rsyncd.secrets /cygdrive/d/rsync
5.可以把windows目录上传到linux下:
@ECHO OFF
d:
cd “Program Files\cwRsync\bin”
chmod 600 rsync.secrets
rsync -vzrtopg –progress -delete /cygdrive/d/rsync –password-file=/cygdrive/d/rsync/rsyncd.secrets
把windwos上rsync 目录上传到linux上