Skip to content

Instantly share code, notes, and snippets.

@eirsyl
Created February 17, 2014 23:29
Show Gist options
  • Save eirsyl/9061420 to your computer and use it in GitHub Desktop.
Save eirsyl/9061420 to your computer and use it in GitHub Desktop.
Dump / Restore Postgres Database
su postgres
pg_dump dbname > outfile
psql dbname < infile
# Chango owner onn all tables
for tbl in `psql -qAt -c "select tablename from pg_tables where schemaname = 'public';" "dbname"` ; do psql -c "alter table $tbl owner to ownername" "dbname" ; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment