postgresql pg_restore:找不到命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19939281/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 01:11:11  来源:igfitidea点击:

pg_restore: command not found

ruby-on-railspostgresqlheroku

提问by Kevin Ciminelli

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:

我有一个使用 Postgresql 数据库托管在 Heroku 上的 RoR 应用程序,并且一直在使用 PG Backups 工具将数据库从我的应用程序备份到我的本地机器上。由于该应用程序仍在开发中,它从编程的角度帮助我减少同事对数据库所做的更改。我已经成功地使用 PG 备份来捕获和恢复几个月但最近,当我运行我的典型命令时,如下所示:

$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:

在 curl 命令执行后,我收到此错误:

-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.

关于为什么会发生这种情况的任何想法?显然问题是我无法恢复下载的备份。

回答by hgmnz

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.

听起来您的本地环境发生了一些变化,现在pg_restore,与 pg_dump 和 psql 一起与 postgres 捆绑在一起的客户端命令工具不可用。

Sounds like you need to set your PATH correctly.

听起来您需要正确设置 PATH。

Try finding the correct pg_restorein your system with maybe sudo find / -name pg_restore, and after you do add it's directory to PATH.

尝试pg_restore在您的系统中找到正确的可能sudo find / -name pg_restore,然后将其目录添加到 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.

最后,您正在做的事情可能可以通过一个更简单的heroku pg:pull.