您好,登錄后才能下訂單哦!
文件名:ggbackup.sh
路徑$HOME/ggscript/ggbackup
因為在2016年下半年我們的一個數(shù)據(jù)同步服務(wù)器因為存儲損壞導(dǎo)致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
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。