Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have downloaded the database from an existing Heroku app onto my local machine. The data I downloaded is in a single file; let's call it herokuapp.db. I also have Postgres installed and I can successfully create a new Postgres database and have my Rails app reference that. What I want to do is move the data I downloaded from Heroku into this database or create a new Postgres database using the downloaded data.

share|improve this question

2 Answers

up vote 2 down vote accepted

Use pg_restore --verbose --clean --no-acl --no-owner -d [database_name] [herokuapp.db] see https://devcenter.heroku.com/articles/export-from-heroku-postgres for more information

share|improve this answer
 
gracias, that did it. –  wuliwong Nov 13 '12 at 22:25

I just solved the same problem with a similar technique that Will suggested (thanks Will!).

$ heroku pgbackups:capture
$ curl -o latest.dump `heroku pgbackups:url`
$ pg_restore --verbose --clean --no-acl --no-owner -d [database_name] latest.dump

The database_name can be found in the development section of the database.yml file.

EDIT
I recently performed this task again with Postgres.app and the last command above did not work. I was getting this error message:

pg_restore: connecting to database for restore
pg_restore: [archiver (db)] connection to database "[database_name]" failed: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
pg_restore: *** aborted because of error

Here is the updated command that worked:

$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U $USER -d [database_name] latest.dump
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.