侧边栏壁纸
博主头像
爱运维 博主等级

行动起来,活在当下

  • 累计撰写 197 篇文章
  • 累计创建 143 个标签
  • 累计收到 21 条评论

目 录CONTENT

文章目录

rsync服务端的脚本一键安装

Administrator
2016-12-11 / 0 评论 / 0 点赞 / 2 阅读 / 0 字

上文我们用了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

0

评论区