上文我们用了rsync来同步数据,这里讲讲rsync daemon服务端的脚本一键安装、
备份网站数据脚本: https://www.iyunw.cn/archives/179
#!/bin/bash #部署rsync daemon #Tommy Lin #2016-12-10 BACKDIR=/backup username=rsync_backup password='lyy123456' function chick_rsync(){ if [ `rpm -qa |grep rsync|wc -l` -eq 0 ];then { echo "rsync is not install,install......." sleep 3 yum install -y rsync } else echo "rsync is install..." fi } function install_rsyncdconf(){ echo >/etc/rsyncd.conf<<'EOF' uid = rsync gid = rsync use chroot = no max connections = 2000 timeout = 6000 pid file = /var/run/rsyncd.pid lock file = /var/run/rsync.lock log file = /var/log/rsyncd.log ignore errors read only = false list = false auth users = rsync_backup secrets file = /etc/rsync.password ############################ [backup] comment = www by BACKUP path = /backup EOF } function INSTALL(){ echo "$username:$password">/etc/rsync.password useradd -s /sbin/nologin -M rsync chmod 600 /etc/rsync.password install_rsyncdconf sed -i "s#auth users = rsync_backup#auth users = $username#g" /etc/rsyncd.conf sed -i "s#path = /backup#path = $BACKDIR#g" /etc/rsyncd.conf if [ -d $BACKDIR ] ;then echo "$BACKUP OK" else mkdir -p $BACKDIR chown -R rsync.rsync $/BACKDIR fi } INSTALL /usr/bin/rsync --daemon echo "/usr/bin/rsync --daemon >/dev/null 2>&1" >>/etc/rc.d/rc.local有疑问联系我邮箱:351937287@qq.com
评论区