Skip to content

Instantly share code, notes, and snippets.

@e0da
Last active December 16, 2015 22:20
Show Gist options
  • Save e0da/5506429 to your computer and use it in GitHub Desktop.
Save e0da/5506429 to your computer and use it in GitHub Desktop.
#!/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