Latest 100 public snipts »
Fotinakis's
snipts » pgdump
showing 1-1 of 1 snipts for pgdump
-
∞ Make copy and transfer entire PostgreSQL DB
pg_dump -d prod_db -U prod_db -h localhost > /tmp/transferdump.sql psql -U prod_db_user -h localhost -t -d other_db -c "SELECT 'DROP TABLE ' || n.nspname || '.' || c.relname || ' CASCADE;' FROM pg_catalog.pg_class AS c LEFT JOIN pg_catalog.pg_namespace AS n ON n.oid = c.relnamespace WHERE relkind = 'r' AND n.nspname NOT IN ('pg_catalog', 'pg_toast') AND pg_catalog.pg_table_is_visible(c.oid)" >/tmp/dropothertables.sql; psql -d other_db -h localhost -U other_db_user < /tmp/dropothertables.sql; psql -d other_db -h localhost -U other_db_user < /tmp/transferdump.sql


