Linux系统与windows系统rsync同步数据

环境:
Linux:centos7.6 服务IP:11.11.31.227 需要传输的文件路径:/root/test
Windows:W10 服务IP:11.11.31.215 存放传输文件的文件夹:D:/www
1、服务器端安装、部署rsync
(1)rpm -ivh rsync-3.1.2-4.el7.x86_64.rpm
(2)vi /etc/rsyncd.passwd #里面内容:root:pwd@123
(3)chmod 600 /etc/rsyncd.passwd #给密码文件赋予读写权限
(4)

vi /etc/rsyncd.conf
uid=0
gid=0
max connections=10 #最大连接数
log file=/var/log/rsyncd.log
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsyncd.lock
port=9940  #端口,可自行设置(需要注意的是,端口必须是在服务器开放端口区间范围内)
[chat]    #标识符,在客户端是需要使用,可自行设置
hosts=11.11.31.215  #客户端地址
comment=backup file
path=/root/test  #服务端需要同步的文件地址
read only = no
exclude=test
auth users=root
secrets file=/etc/rsyncd.passwd  #服务端配置的密码文件

(5)启动服务

[root@localhost test]# /usr/bin/rsync --daemon --config=/etc/rsyncd.conf   #启动rsync服务
[root@localhost test]# echo "/usr/bin/rsync --daemon --config=/etc/rsyncd.conf">>/etc/rc.local #设置开机自启动
[root@localhost test]# netstat -nlpt | grep 9940   查看端口

2、客户端安装、部署cwrsync
(1)找到安装路径的bin目录,将此目录加入到环境变量path中
(2)进入cmd,输入命令:rsync.exe -vzrtopgu --port=9940 --progress --delete root@11.11.31.227::chat /cygdrive/D/www ,出现以下界面,输入密码即可传输文件:
在这里插入图片描述

(3)完善解决方案:
创建bat脚本“照片同步.bat”,并添加到任务计划中:

echo pwd@123|rsync.exe -vzrtopgu --port=9940 --progress --delete root@11.11.31.227::chat /cygdrive/D/webapp/rlsbjpg/DIC_PHOTOTYPE_EMPLOYEE
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值