1

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.

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.