重建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


你可能感兴趣的:(shell,postgrsql)