Skip to main content

Dump / Restore

Dump All Functions (to a file)

SELECT pg_get_functiondef(f.oid) FROM pg_catalog.pg_proc f
INNER JOIN pg_catalog.pg_namespace n ON (f.pronamespace = n.oid)
WHERE n.nspname = 'public';
  • run \o functions.sql first to save the output to a file or
  • use \copy (...) to

Dump database

pg_dump -U username -h hostname databasename > dump.sql

Import info existing database

psql -d newdb -f dump.sql

Dump and Restore Sperling Database

pg_dump --no-owner -U sperling_prod -h sperling_prod > dump.sql

psql -h localhosst sperling_devel postgres -f dump.sql