说明:html
一、RsyncServer服务端linux
系统:CentOS 6.8数据库
IP地址:192.168.247.141vim
二、Rsync客户端windows
系统:Windows10tcp
实现目的:post
Rsync客户端同步服务端/data/test下的文件到E/test下ui
一 、在linux上安装rsyncurl
一、#rpm -qa|grep rsyncspa
yum install rsync -y
二、vim /etc/rsyncd.conf
uid=root gid=root max connections=10 log file=/var/log/rsyncd.log pid file=/var/run/rsyncd.pid lock file=/var/run/rsyncd.lock secrets file=/etc/rsyncd.passwd #本机上运行的数据库备份的模块配置 [www] comment=backup file path=/data/test read only = no exclude=test auth users=root secrets file=/etc/rsyncd.passwd
三、编辑密码文件(密码可自定义):
[root@host1 15:11:29/data/test]# cat /etc/rsyncd.passwd root:123456
四、启动rsync
/usr/bin/rsync --daemon --config=/etc/rsyncd.conf
[root@host1 15:11:25/data/test]# netstat -nlpt | grep 873 tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 46127/rsync tcp 0 0 :::873 :::* LISTEN 46127/rsync
2、windows客户端安装rsync
一、安装cwRsync_4.2.0_Installer
二、打开CMD命令,进入到rsync的执行目录,而后执行命令同步到E盘test文件下
C:\Program Files (x86)\cwRsync\bin>rsync.exe -vzrtopgu --progress --delete root@192.168.247.141::www /cygdrive/E/test
输入服务端密码文件里的密码,而后回车
能够看出已经有删除和同步文件到E:\test
三、无密码输入同步:
把服务端的/etc/rsyncd.passwd文件下载到客户端指定位置(本身随意指定,我放的是E:\rsyncd.passwd),而后删除前面的"root:",即只保留密码便可
CMD命令输入:
rsync.exe -vzrtopgu --progress --delete root@192.168.247.141::www /cygdrive/E/test --password-file=/cygdrive/E/rsyncd.passwd