Trying to pull Heroku database onto my localhost

271 Views Asked by At

I recently made a mistake by rolling back my database too far on my localhost and removed all the data from within the databases I've had. I did migrate the databases so they would return but they still were cleaned out.

Asking around what to do next, I was told that I should backup the database on Heroku (which has all the current information) and pull it onto my localhost. If this is the correct action to take, then I am still facing a problem. When I type: heroku pg:pull DATABASE_URL mylocaldb --app (my_app_name) it returns an error of:

sh: createdb: command not found
!    
! Unable to create new local database. Ensure your local Postgres is
working and try again.

I do not have the best understanding of databases as I am newer; however, I have downloaded sql on my local machine. All of the commands I input are in the regular console and not the psql terminal.

If anyone has any knowledge or can help me, I would greatly appreciate it. Thank you so much!

Joe

Edit: If you do have another method/solution, please let me know. I cannot update my application until I have this done so I do not lose my information.

1

There are 1 best solutions below

3
On

I would try using backup/restore:

heroku pg:backups --app MYAPPNAME capture
curl -o latest.dump `heroku pg:backups --app MYAPPNAME public-url`

as (almost) documented at https://devcenter.heroku.com/articles/heroku-postgres-import-export

Note the strange placement of --app MYAPPNAME. It needs to go immediately after the heroku sub-command and before any other arguments.