first commit
This commit is contained in:
commit
ba848e218d
1001 changed files with 152333 additions and 0 deletions
68
shell/rsync同步/rsync_client_dr.sh.md
Normal file
68
shell/rsync同步/rsync_client_dr.sh.md
Normal file
|
@ -0,0 +1,68 @@
|
|||
```
|
||||
#!/bin/bash
|
||||
|
||||
##Edit by wangsuipeng
|
||||
##Date 2016/10/25
|
||||
|
||||
## Rsync 客户端脚本-用于灾备环境搭建
|
||||
##
|
||||
## 脚本说明:
|
||||
##
|
||||
## 操作说明:执行过本脚本以后,需要添加到定时任务中
|
||||
## 并删除定时任务中的其他应用同步命令,即
|
||||
## 带有/opt/appl/assist/rsync/的脚本,为
|
||||
## 安全起见,请确认是否是应用同步脚本
|
||||
|
||||
|
||||
##项目名
|
||||
read -p "The Project name[Not username]:" PRO_NAME
|
||||
|
||||
##服务端IP
|
||||
read -p "The Server IP:" PRO_HOST_IP
|
||||
|
||||
##容器
|
||||
read -p "The Software[jboss/tomcat]:" SOFT
|
||||
|
||||
yum -y install rsync xinetd > /dev/null 2>&1
|
||||
##脚本存放位置
|
||||
DIRPATH=/usr/local/rsync
|
||||
|
||||
##密码文件
|
||||
PASS_CFG=$DIRPATH/rsyncd.pass
|
||||
|
||||
##脚本文件
|
||||
SCRIPT=$DIRPATH/rsync_${PRO_HOST_IP}-${PRO_NAME}.sh
|
||||
|
||||
EXCLUDE_CONF()
|
||||
{
|
||||
cat > /usr/local/rsync/exclude << EOF
|
||||
log/*
|
||||
logs/*
|
||||
temp/*
|
||||
backup/*
|
||||
deployment/*
|
||||
*.tar.gz
|
||||
*.tgz
|
||||
*.log
|
||||
*.out
|
||||
jdk*
|
||||
work/*
|
||||
EOF
|
||||
}
|
||||
|
||||
if [ -d $DIRPATH ]
|
||||
then
|
||||
if [ -f $DIRPATH/rsyncd.pwd ]
|
||||
then
|
||||
cd $DIRPATH && tar zcvf bak.`date +%d%H%M`.tar.gz --exclude *.tar.gz * --remove-files >/dev/null 2>&1
|
||||
fi
|
||||
else
|
||||
mkdir -p $DIRPATH
|
||||
fi
|
||||
|
||||
EXCLUDE_CONF
|
||||
echo "#!/bin/bash" > $SCRIPT
|
||||
echo "/usr/bin/rsync -arP --delete --bwlimit=200 --exclude-from=/usr/local/rsync/exclude --password-file=$PASS_CFG rsync@$PRO_HOST_IP::${PRO_NAME}19 /opt/appl/$PRO_NAME/$SOFT" >> $SCRIPT
|
||||
chmod +x $SCRIPT
|
||||
echo "123456" > $PASS_CFG
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue