Skip to content

Instantly share code, notes, and snippets.

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 bellerbrock/02628c03f1c5c673c55f490dc64ad4cf to your computer and use it in GitHub Desktop.
Save bellerbrock/02628c03f1c5c673c55f490dc64ad4cf to your computer and use it in GitHub Desktop.
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