侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

windows下rsync无密码同步

2023-11-19 星期日 / 0 评论 / 0 点赞 / 43 阅读 / 3425 字

在windows环境下实现rsync无密码同步 环境配置如下: 1、rsync server:192.168.0.251 2、rsync client:192.168.20.19 两个ip地址相互

在windows环境下实现rsync无密码同步

环境配置如下:

1、rsync server:192.168.0.251 

2、rsync client:192.168.20.19    

两个ip地址相互能ping通,能访问,因为我公司I的网络环境是多ip,多vlan的。

一、rsync server 配置文件如下:

uid=nobody
gid=nobody
address = 192.168.0.251
port=873
hosts allow= 192.168.20.0/24
#hosts deny=0.0.0.0/32
use chroot=yes
max connections=5
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsync.lock
log file=/var/log/rsyncd.log
motd file=/etc/rsyncd.motd

[wwwroot]     
path=/usr/local/nginx/html  需要同步的文件夹
#comment=rsync wwwroot to backup
read only=no      //权限是否给只读 
#list=yes
#auth users=root 
#secrets file=/etc/rsync.passwd

二、rsync client配置文件:

@ECHO OFF
REM *****************************************************************
REM
REM CWRSYNC.CMD - Batch file template to start your rsync command (s).
REM
REM By Tevfik K. (http://itefix.no)
REM *****************************************************************

REM Make environment variable changes local to this batch file
SETLOCAL

REM ** CUSTOMIZE ** Specify where to find rsync and related files (C:/CWRSYNC)
SET CWRSYNCHOME=%PROGRAMFILES%/CWRSYNC

REM Set HOME variable to your windows home directory. That makes sure 
REM that ssh command creates known_hosts in a directory you have access.
SET HOME=%HOMEDRIVE%%HOMEPATH%

REM Make cwRsync home as a part of system PATH to find required DLLs
SET CWOLDPATH=%PATH%
SET PATH=%CWRSYNCHOME%/BIN;%PATH%

REM Windows paths may contain a colon (:) as a part of drive designation and 
REM backslashes (example c:/, g:/). However, in rsync syntax, a colon in a 
REM path means searching for a remote host. Solution: use absolute path 'a la unix', 
REM replace backslashes (/) with slashes (/) and put -/cygdrive/- in front of the 
REM drive letter:
REM 
REM Example : C:/WORK/* --> /cygdrive/c/work/*
REM 
REM Example 1 - rsync recursively to a unix server with an openssh server :
REM
REM       rsync -r /cygdrive/c/work/ remotehost:/home/user/work/
REM
REM Example 2 - Local rsync recursively 
REM
REM       rsync -r /cygdrive/c/work/ /cygdrive/d/work/doc/
REM
REM Example 3 - rsync to an rsync server recursively :
REM    (Double colons?? YES!!)
REM
REM       rsync -r /cygdrive/c/doc/ remotehost::module/doc
REM
REM Rsync is a very powerful tool. Please look at documentation for other options. 
REM

REM ** CUSTOMIZE ** Enter your rsync command(s) here


cd "D:/Program Files (x86)/cwRsync/bin"    //切换到rsync客户端的bin目录下
rsync.exe -avzP --progress --delete rsync://192.168.0.251:873/wwwroot /cygdrive/D/251backup     

三、客户端通过“任务计划程序” 添加定时计划,实现自动同步。 

-完-

广告 广告

评论区