I have a RoR application hosted on Heroku using a Postgresql database and have been using the PG Backups tool to backup the database from my application on to my local machine. Since the application is still in development, it helps me from a programming standpoint to bring down the changes my colleagues are making to the database. I have been successfully using PG Backups to capture and restore for months but lately, when I run my typical commands as seen here:
$curl -o latest.dump `heroku pgbackups:url --app XXXXX`
$pg_restore --verbose --clean --no-acl --no-owner -h localhost -U XXXXX -d XXXXX_development latest.dump
I am getting this error after the curl command goes through:
-bash: pg_restore: command not found
Any ideas on why this is happening? Obviously the problem is that I can't restore the downloaded backup.
pg_dump, pg_dump_all, pg_restore are all located in the bin folder of the PostgreSQL install and PgAdmin III install.
pg_restore is a utility for restoring a PostgreSQL database from an archive created by pg_dump in one of the non-plain-text formats. It will issue the commands necessary to reconstruct the database to the state it was in at the time it was saved.
Go to Edit the system environment variables. Then Environement variables. Then Path then add the location of bin of postgres in my case C:\Program Files\PostgreSQL\14\bin\ Click ok on each open window.
Sounds like something changed in your local environment, and now pg_restore
, a client command tool bundled with postgres alongside pg_dump and psql, is not available.
Sounds like you need to set your PATH correctly.
Try finding the correct pg_restore
in your system with maybe sudo find / -name pg_restore
, and after you do add it's directory to PATH.
Finally, what you're doing could possibly be accomplished with a simpler heroku pg:pull
, which takes a backup from your heroku database and restores it locally all in one command (but also uses pg_dump/pg_restore, so those need to be available as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With