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.
-
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.
-
obtain your database password from the "database" tab in the Ninefold portal.
-
put the password where Postgres can find it (on the database server):
echo "localhost:*:*:app:<PASSWORD>" > ~/.pgpass
thenchmod 0600 .pgpass
more info on password files -
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.