您好,登錄后才能下訂單哦!
文件名:ggbackup.sh
路徑$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
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。