重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
文件名:ggbackup.sh
创新互联建站主营威县网站建设的网络公司,主营网站建设方案,app软件开发公司,威县h5成都小程序开发搭建,威县网站营销推广欢迎威县等地区企业咨询
路径$HOME/ggscript/ggbackup
因为在2016年下半年我们的一个数据同步服务器因为存储损坏导致OGG配置文件丢失,被迫重新部署的情况。因此特别针对该情况编写了自动备份OGG进程配置信息脚本。
#!/bin/bash cd $HOME/ggscript/ggbackup dir=$PWD cd $HOME if [ -f .profile ];then . .profile fi if [ -f .bash_profile ];then . .bash_profile fi mydate=`date +20%y-%m-%d-%H` hn=`echo $HOSTNAME` usr=`echo $USER` dr=`echo $hn-$usr` cd $dir echo $dir if [ ! -d $dr ];then mkdir $dr && echo "Directory $hn-$user created." || echo "Error: Failed to create directory $dr." else echo "$dr directory exits!" fi if [ ! -d $dr/dirprm ];then mkdir $dr/dirprm && echo "Directory $dr/dirprm created." || echo "Error: Failed to create directory $dr/dirprm." else echo "$dr/dirprm directory exits!" fi if [ ! -d $dr/dirpcs ];then mkdir $dr/dirpcs && echo "Directory $dr/dirpcs created." || echo "Error: Failed to create directory $dr/dirpcs." else echo "$dr/dirpcs directory exits!" fi if [ ! -d $dr/info ];then mkdir $dr/info && echo "Directory $dr/info created." || echo "Error: Failed to create directory $dr/info." else echo "$dr/info directory exits!" fi cd $HOME/ggserver (echo info all;echo exit)|./ggsci|grep -E "EXTRACT|REPLICAT" |awk 'BEGIN {FS=" +"} {print $3}' > $HOME/ggscript/ggbackup/temp num=`sed -n '$=' $dir/temp` i=1 while [ "$i" -le "$num" ] do VAR=`sed -n $i'p' $dir/temp` #echo $VAR var=`echo $VAR| tr "[:upper:]" "[:lower:]"` #echo $var find $HOME/ggserver/dirprm -name $var.prm -exec cp {} $dir/$dr/dirprm/ \; find $HOME/ggserver/dirpcs -name $VAR.pc* -exec cp {} $dir/$dr/dirpcs/ \; (echo info $VAR;echo exit)|./ggsci > $dir/$dr/info/$VAR i=`expr $i + 1` done find $HOME/ggserver/dirprm -name mgr.prm -exec cp {} $dir/$dr/dirprm/ \; find $HOME/ggserver/dirpcs -name MGR.pc* -exec cp {} $dir/$dr/dirpcs/ \; (echo exit)|./ggsci|grep Oracle > $dir/$dr/version (echo exit)|./ggsci|grep Version >> $dir/$dr/version cd $dir zip -r $dr.zip $dr /bin/bash $HOME/ggscript/ggupload/upload.sh backup $dir/$dr.zip sysinfo