Last active
December 16, 2015 22:20
-
-
Save e0da/5506429 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
ALREADY_LOADED=admin_sample_database_already_loaded | |
DUMPFILE=/vagrant_support/admin_sample.sql | |
DATABASE=admin__default | |
if [[ ! -f $DUMPFILE ]]; then | |
print "You must supply the pg_dump file at $DUMPFILE first." | |
exit 1 | |
fi | |
if [[ ! -f $ALREADY_LOADED || "$1" == '--force' ]]; then | |
print "Loading $DATABASE from $DUMPFILE..." | |
set -x | |
pg_restore -U vagrant $DUMPFILE -c -d $DATABASE | |
touch $ALREADY_LOADED | |
set +x | |
exit 0 | |
else | |
print "The database has already loaded. You can force loading it with" | |
print "$0 --force" | |
exit 2 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment