Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pg_restore: command not found

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.

like image 216
Kevin Ciminelli Avatar asked Nov 12 '13 20:11

Kevin Ciminelli


People also ask

Where is Pg_restore?

pg_dump, pg_dump_all, pg_restore are all located in the bin folder of the PostgreSQL install and PgAdmin III install.

What is Pg_restore in Postgres?

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.

Can not find pg_dump in a system?

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.


1 Answers

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.

like image 119
hgmnz Avatar answered Oct 18 '22 11:10

hgmnz