sql for granting web_usr roles to breedbase db. Useful when the roles get messed...
[sgn-devtools.git] / test-load-db.sh
blob77b73de748dbfe86be4053225f14dfe4e2d2752f
1 #!/bin/sh
3 # test if database exists
4 echo "Checking if database exists..."
5 sudo -u postgres psql -l | grep -q cxgn_daily_build && sudo -u postgres dropdb -U postgres cxgn_daily_build
7 ### deanx - Oct 02 2007 - originally the createdb statement was part of the DB load
8 # below. But I found that caused login/sudo confusion and failed. now
9 # the createdb is simply a seperate step
10 echo "Create new database for the daily build..."
11 sudo -u postgres createdb -E SQL_ASCII cxgn_daily_build
12 ###
14 echo "Loading database from dump (this may take a while...)"
15 # reload the database from file given as parameter
16 { zcat -f "$1" ; echo COMMIT ; } |
17 sudo -u postgres psql -U postgres --echo-all --variable AUTOCOMMIT=off --variable ON_ERROR_STOP=t \
18 --dbname cxgn_daily_build > ${2:-/tmp/cxgn_daily_build_creation_log} 2>&1 || \
19 { dropdb -U postgres cxgn_daily_build; echo Database load failed! > /dev/stderr ; exit 1; }