Created
March 30, 2014 23:30
-
-
Save dux/9881717 to your computer and use it in GitHub Desktop.
get remote postgree database
This file contains hidden or 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 | |
[email protected] | |
REMOTE_DB_NAME=db_production | |
REMOTE_DB_USER=db_user | |
REMOTE_DB_PASS=db_pass | |
LOCAL_DB=db_local | |
echo $REMOTE_DB_PASS | pbcopy | |
ssh $REMOTE_HOST "pg_dump --host localhost --port 5432 --username $REMOTE_DB_USER --password $REMOTE_DB_NAME" > prod_database.sql | |
dropdb $LOCAL_DB | |
createdb -T template1 $LOCAL_DB | |
psql -d $LOCAL_DB -f prod_database.sql | |
rm -rf prod_database.sql | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment