rsync 文件同步
Linux Server : 192.168.1.63
vim /etc/rsyncd.conf
# /etc/rsyncd.conf #全局配置部分 secrets file = /etc/rsyncd.secrets read only = no write only = no list = yes uid = root gid = root charset=UTF-8 #允许指定的主机连接 #hosts allow = 192.168.1.52 172.18.1.50 #允许任何主机 host allow = * #禁止指定的主机连接 #hosts deny = 192.168.1.1/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 #模块配置 [rsynctest] comment = sync directory path = /home/dennis/Documents auth users = rsync secrets file = /etc/rsyncd.secrets
create password file
echo "rsync:rsync" > /etc/rsyncd.secrets chown root:root /etc/rsyncd.secrets chmod 600 /etc/rsyncd.secrets
start rsync
# 查询是否存在rsync进程 ps aux | grep rsync # 启动rsync rsync --daemon # 检查 rsync 使用的873端口正常监听 netstat -an | grep 873
Linux Clint : 192.168.1.52
create password file
# 该步骤主要用于解决同步过程需要手动输入密码问题 echo "rsync" > /etc/rsyncd.secrets chown root:root /etc/rsyncd.secrets chmod 600 /etc/rsyncd.secrets
download
# 需要手动输入密码 rsync -vzrtopg --delete --progress rsync@192.168.1.63::rsynctest /root/rsyntest/ # 不需要输入密码 rsync -vzrtopg --delete --progress --password-file=/etc/rsyncd.secrets rsync@192.168.1.63::rsynctest /root/rsyntest/
upload
# 需要手动输入密码 rsync -vzrtopg --delete --progress ./*.log rsync@192.168.1.63::rsynctest # 不需要输入密码 rsync -vzrtopg --delete --progress --password-file=/etc/rsyncd.secrets ./*.log rsync@192.168.1.63::rsynctest
Windows Clint : 192.168.1.42
Install cwRsync_2.0.10
create password file
mkdir d:/rsync echo "rsync" > d:/rsync/rsyncd.secrets
change to then install directory
cd C:\Program Files\cwRsync\bin
download
rsync -vzrtopg --progress --delete --password-file=/cygdrive/d/rsync/rsyncd.secrets rsync@192.168.1.63::rsynctest /cygdrive/d/rsync
upload
rsync -vzrtopg --progress --delete --password-file=/cygdrive/d/rsync/rsyncd.secrets /cygdrive/d/rsync rsync@192.168.1.63::rsynctest