Skip to content

Instantly share code, notes, and snippets.

@rmanocha
Created July 30, 2009 07:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmanocha/158602 to your computer and use it in GitHub Desktop.
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
#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