rsync 服务端配置与同步验证
#!/bin/bash
######################
#int
CHECK=`rpm -qa rsync|wc -l`
HOSTIP="192.168.1.0/24"
#rsync
PWD="123456"
USER="rsync_umbe"
PWD_PATH="/etc/rsyncd/rsync.pwd"
RSYNC_USER="rsync"
#loadsys functions
[-f /etc/init.d/functions] && . /etc/init.d/functions
RETVAL=0
#check rsync
if ["$CHECK" -eq 1];then
action "Rsync is installed" /bin/true
else
echo "error:rsync in not install"
echo "yum install -y rsync"
yum install rsync -y >>/tmp/rsync_install.log
echo "-------------------" >>/tmp/rsync_install.log
action "rsync in installed" /bin/true
fi
#edit rsync.conf
if [! -f /etc/rsyncd.conf];then
cat >>/etc/rsyncd.conf< >/etc/rsyncd/rsync.pwd 0
chmod 600 /etc/rsyncd/rsync.pwd
fi
action "rsync configure successful" /bin/true
##START IP RSYNC
rsync --daemon
[`ps -ef|grep rsync|grep -v grep|wc -l` -eq 1] && {
action "rsync cofigure seccessful" /bin/true
exit $RETVAL
}
补充说明:第一次应先验证路径映射和权限,再同步真实数据。若启用删除选项,必须先做预演并确认目标不是唯一副本。