Search code examples
ruby-on-railsdatabaseherokudatabase-backupspg

PG Restore function not working on localhost


I'm trying to restore a backup to my localhost machine to review the data - so that I can actually make sure the backup is working. I'm using Heroku, postgres, and rails.

I clean installed the app, so there is no data in the localhost database. I ran db:reset, and db:migrate.

Here is the string I'm trying to use for pg_restore:

 pg_restore --verbose --clean --no-acl --no-owner -h localhost -p 3000 -U ian -d backup_production latest.dump

The error I receive says:

"connection to database "backup_production" failed: server closed the connection unexpectedly"

I've never had to do this before, so any help would be appreciated. I assume that development is what localhost uses (instead of test or production)?

I'm not sure what I'm missing, but I'll answer any question you may have.

Thanks a lot.

edit,. Here is a question, for this database string I assumed that I need to to use all the localhost information, because I created a backup using heroku capture/download. Am I wrong in that assumption? Should I instead be using the database name and port, etc, from the heroku credentials?


Solution

  • Turns out, I shouldn't have added the port. Removing -p 3000 , made this command work.