Skip to content

Instantly share code, notes, and snippets.

@tjmcewan
Last active December 26, 2015 11:59
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 tjmcewan/7147476 to your computer and use it in GitHub Desktop.
Save tjmcewan/7147476 to your computer and use it in GitHub Desktop.
Ninefold db updates

This is a quick way to Push or Pull your app database between your local machine and your Ninefold app server. "Pushing" is useful in the early stages of app development when you need to update seed data. "Pulling" is eternally useful for debugging.

  1. setup public key authentication (the SSH username is "user"). NB ensure you don't remove the existing SSH key - it's needed by the Ninefold Portal.

  2. obtain your database password from the "database" tab in the Ninefold portal.

  3. put the password where Postgres can find it (on the database server): echo "localhost:*:*:app:<PASSWORD>" > ~/.pgpass then chmod 0600 .pgpass more info on password files

  4. create these aliases on your local machine (NB: either both commands DESTROY the destination database):

alias dbpull='ssh user@<DB SERVER IP> "pg_dump --clean -h localhost -Z 9 -U app <REMOTE DB NAME>" | zcat | psql <LOCAL DB NAME>'
alias dbgpush='pg_dump --clean -Z 9 <LOCAL DB NAME> | ssh user@<DB SERVER IP> "zcat | psql -h localhost -U app <REMOTE DB NAME>"'

with credit to Tobias.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment