Created
August 14, 2013 01:01
-
-
Save tanraya/6227167 to your computer and use it in GitHub Desktop.
Synchronize postgres production database with local development. NOTE: you need to create .pgpass file on production first.
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
| ssh er -t 'pg_dump -h localhost -U estrabota estrabota_production | gzip > /tmp/estrabota.gz' | |
| scp er:/tmp/estrabota.gz ./tmp | |
| psql -U postgres -c "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'estrabota_development';" | |
| psql -U postgres -c "DROP DATABASE estrabota_development;" | |
| psql -U postgres -c "CREATE DATABASE estrabota_development WITH TEMPLATE = template0 ENCODING = 'UNICODE' OWNER estrabota;" | |
| gunzip -c ./tmp/estrabota.gz | psql -U postgres estrabota_development |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment