Database Setup - scholarslab/prism GitHub Wiki
Homebrew Setup
You'll need to install Postgresql on your laptop.
$ brew update
$ brew install postgresql
$ initdb /usr/local/var/postgres
Note
By default, Postgresql installed through homebrew uses the same user account which you install postgresql with in homebrew (e.g. waynebot). This is fine for the development environment, but shouldn't be used in production.
Launch Postgresql
I typically don't have Postgresql launch on startup as it takes system resources I don't always want to yield for that convenience. Instead of running the pg_ctl
, I tend to run postgresql when I need it with the following:
$ postgres -D /usr/local/var/postgres
Create a backup
The Postgresql backups operate on your primary database (at the DATABASE_URL
config var location). To start a backup, execute the capture
task in the heroku toolkit.
$ heroku pgbackups:capture --app [app-name]
HEROKU_POSTGRESQL_BLACK (DATABASE_URL) ----backup---> b251
Capturing... done
Storing... done
Download the backup
Download the latest dump from the DATABASE_URL
:
$ curl -o latest.dump `heroku pgbackups:url --app [app-name]`
Restore the local copy
You can load the data using the pg_restore
tool.
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U user -d prism latest.dump