Created
April 28, 2016 22:31
-
-
Save bellerbrock/02628c03f1c5c673c55f490dc64ad4cf to your computer and use it in GitHub Desktop.
This file contains 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
to dump production db: | |
from commandline: pg_dump -U postgres -h db5.sgn.cornell.edu cxgn_musabase | db5.cxgn_musabase.pgsql.gz | |
to rename old test db: | |
ALTER DATABASE sandbox_musabase RENAME TO sandbox_musabase_backup | |
if there is an error, check for active processes: SELECT * FROM pg_stat_activity; | |
and force disconnect of processes (should be idle!): | |
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE pid <> pg_backend_pid( ) AND datname = 'sandbox_musabase'; | |
the run ALTER command again, or remove it: | |
DROP DATABASE sandbox_musabase; | |
to create new testdb and load productiondb dump: | |
CREATE DATABASE sandbox_musabase TEMPLATE template0; | |
then from commandline: gunzip -c db5.cxgn_musabase.pgsql.gz | psql -U postgres -h db4.sgn.cornell.edu sandbox_musabase |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment