Skip to content

Instantly share code, notes, and snippets.

@donrestarone
Last active November 14, 2020 13:54
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 donrestarone/f42d80fca6d8037c1d7e6b9eaa8cfd75 to your computer and use it in GitHub Desktop.
Save donrestarone/f42d80fca6d8037c1d7e6b9eaa8cfd75 to your computer and use it in GitHub Desktop.
pulling a db dump from heroku and restoring your local database with it

first grab the latest.dump from heroku

heroku pg:backups:capture
heroku pg:backups:download

then make sure that you have a database user with a password setup

sudo su postgres
CREATE ROLE test;
ALTER ROLE test with LOGIN;
ALTER USER test with CREATEDB;
ALTER USER test with PASSWORD 'test';
pg_restore -c -C -F c -v -U database_user_name -d database_name latest.dump

ex;

pg_restore -c -C -F c -v -U don -d blog_development latest.dump

alternate:

pg_restore --verbose --clean --no-acl --no-owner -h localhost -U user_name -d database_name_development latest.dump

restore on a remote db:

pg_restore -h 192.168.0.190 -p 5432 -d databasename -U myuser mydump.dump
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment