Created
July 30, 2009 07:03
-
-
Save rmanocha/158602 to your computer and use it in GitHub Desktop.
A Bash Script to automate the process of dropping, creating and importing data into a PostgreSQL DB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#A quick bash script to automate the process of dropping, creating and importing data into a postgresql database. | |
#It takes 2 arguments, the first being the database name and the second being the psql dump file. | |
#This script has only been tested on Mac OS X and assumes your PostgreSQL binaries are in /usr/local/pgsql/bin/ | |
#!/bin/bash | |
export PGPASSWORD='FILL ME' | |
echo "Dropping $1" | |
/usr/local/pgsql/bin/dropdb $1 | |
echo "Creating $1" | |
/usr/local/pgsql/bin/createdb -U postgres $1 -E UTF8 | |
echo "Importing $2 into $1" | |
/usr/local/pgsql/bin/psql -U postgres $1 < $2 | |
echo "All done!!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment