1.linux端安装rsync:
yum -y install rsync
2.linux端配置rsync:
[root@file_server ~]# cat /etc/rsyncd.conf
# /etc/rsyncd: configuration file for rsync daemon mode
# See rsyncd.conf man page for more options.
# configuration example:
uid = nobody
gid = nobody
use chroot = no
max connections = 4
# pid file = /var/run/rsyncd.pid
exclude = lost+found/
transfer logging = yes
timeout = 900
log file = /var/log/rsyncd.log
ignore nonreadable = yes
dont compress = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2
[test_data]
path = /home/mt
list = no
ignore errors
read only = no
hosts allow = *
auth users = root
secrets file = /etc/rsyncd/rsyncd.passwd
# [ftp]
# path = /home/ftp
# comment = ftp export area
3.linux端创建/etc/rsyncd/rsyncd.passwd并写入通信时用的账号和密码
[root@file_server ~]# cat /etc/rsyncd/rsyncd.passwd
root:123456
4.Linux端启动rsyncd.service服务
systemctl start rsyncd
5.linux端放行rsyncd服务端口
[root@file_server ~]# firewall-cmd --zone=public --add-port=873/tcp --permanent
[root@file_server ~]# firewall-cmd --reload
6.windows端下载cwrsync
https://itefix.net/dl/free-software/cwrsync_6.2.4_x64_free.ziphttps://itefix.net/dl/free-software/cwrsync_6.2.4_x64_free.zip7.windows端解压文件,并bin目录加入到系统环境变量中
8.在解压目录下新建一个密码文件并写入密码123456(在linux端/etc/rsyncd/rsyncd.passwd里的密码)
9.windows端编写bat文件执行同步操作
@echo off
set logfile=D:\lrh\log\rsync_log.txt
cd D:\cwrsync_6.2.4_x64_free\bin
echo %date:~0,10% %time:~0,-3% >> %logfile%
echo "start sync 1.1.1.1:/home/mt/ to D:/rsync_data " >> %logfile%
rsync.exe --port=873 -avzP --progress --delete --password-file=/cygdrive/D/cwrsync_6.2.4_x64_free/rsync.passwd root@1.1.1.1::test_data/ /cygdrive/D/rsync_data >> %logfile%
echo "sync success" >> %logfile%