重建postgrsql 數據庫腳本

#!/bin/sh
read -p "Do you want to dorp the AcapHisDB database?(yes/no)" a
echo "Please Wait......"
tbpath=$(find / -type d -name "pg_tables")
yes()
{
        /usr/local/pgsql/bin/psql -Upostgres -c "\l" | grep "AcapHisDB" > /dev/null
        if [ $? -eq 0 ]
            then
              /usr/local/pgsql/bin/dropdb -Upostgres AcapHisDB
                if [ -r "/usr/local/pgsql/hdata/" ]
                    then
                      /usr/local/pgsql/bin/psql -Upostgres -c "DROP TABLESPACE hisdbspace;"
                      cd $tbpath
                      ./table_install.sh -h
                    else
                      echo "dbspace not existent"
                      exit 3
                 fi
            else
              echo "database not existent"
              exit 3
        fi
}
no()
{
        exit 1
}
case $a in
    yes|YES)
        yes
        ;;
    no|NO)
        no
        ;;
esac


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章