備份--系統配置表的shell

來源:互聯網
上載者:User

備份--系統配置表的shell 配置使用者名稱密碼檔案report.iniuser1/pswd1@dbname1user2/pswd2@dbname2配置系統資料表檔案configtable.iniuser1.table1user2.table2user3.table3 指令碼backup.sh一次讀取設定檔,並做驗證,如果密碼錯誤則進行修改,將每個使用者的配置表進行匯出備份檔案名稱由使用者輸入或取當前系統時間 #!/usr/bin/ksh dmpfilepath='./'connfile=report.iniconfigtable=configtable.iniif [ "$#" -eq 0 ]then    DT=`date +%Y%m%d%H%M%S`    dateelse    DT=$1fi  #檢查串連串正確性checkconn(){if [ "$#" -ne 1 ]thenecho "-1"exitfi      VALUE=`sqlplus -s /nolog <<EOF    set head off    conn $dbconn    select 1 from dual;    exit    EOF`    echo $VALUE}#將密碼寫入設定檔modipswd(){if [ "$#" -ne 2 ]thenecho "-1"exitfi      user=`echo $1 | cut -d/ -f1`    dbnm=`echo $1 | cut -d@ -f2`    newconn=`echo $dbconn | sed 's/\//\\\\\//g`    cat $2 | sed "/^$user\/.*@$dbnm/s/^.*$/$newconn/g" >temp$$    mv temp$$ $connfile}  #讀取設定檔for dbuser in `cat $configtable | sed -e "s/^ *//g" -e "s/\..*//g" | sort | uniq `do    v_time=0    dbconn=`cat $connfile | grep "^ *$dbuser/"`    checkconn_flg=$(checkconn $dbconn)    while [ "$checkconn_flg" != "1" -a $v_time -lt 3 ]    do        v_time=`expr $v_time + 1`        stty -echo        echo $dbuser@`echo $dbconn | cut -d@ -f2` password is error," Please input new password:\c"        read newpswd        echo ''        dbconn=$dbuser'/'$newpswd'@'`echo $dbconn | cut -d@ -f2`        stty echo        checkconn_flg=$(checkconn $dbconn)        if [ "$checkconn_flg" = "1" ]        then            modipswd $dbconn $connfile            break        fi    done    alltab=''    #讀取配置表    cat $configtable | grep "^ *$dbuser." |    while read dbtab    do        alltab=$alltab,`echo $dbtab | cut -d. -f2`    done    alltab=`echo $alltab | cut -c2-`    if [ -n "$alltab" ]    then        echo :$alltab:        exp $dbconn file=${dmpfilepath}${DT}.$dbuser.dmp tables=\($alltab\)    fi done 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.