Skip to content

Instantly share code, notes, and snippets.

@tdowling
Last active December 12, 2015 07:09
Show Gist options
  • Select an option

  • Save tdowling/4734522 to your computer and use it in GitHub Desktop.

Select an option

Save tdowling/4734522 to your computer and use it in GitHub Desktop.
Copy a database in postgres
/usr/lib/postgresql/9.2/bin/pg_dump -U sofi -n public -h yyc-sofidb01 sofi_production > /tmp/tavis-full.sql; echo 'grant all on database sofi_dev to sofi;' >> /tmp/tavis-full.sql;
sudo su - postgres;
kill `ps -f -U postgres | grep sofi | grep -v grep | awk '{print $2}'` ; dropdb sofi_dev ; createdb sofi_dev ; psql -d sofi_dev -1 -f /tmp/tavis-full.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment