Heroku 在恢复数据库时缺少必需的标志

Heroku missing required flag when restoring database

我看过一些 SO 帖子,尽管使用 google 和 heroku --help,我还是不断收到同样的错误

我一直在努力解决这个问题: https://devcenter.heroku.com/articles/heroku-postgres-import-export

$ heroku pg:backups:restore 'secure-file-location-url' DATABASE_URL --app heroku-app-name --confirm heroku-app-name
Starting restore of secure-file-location-url to postgresql-flat-47715... done

Use Ctrl-C at any time to stop monitoring progress; the backup will continue restoring.
Use heroku pg:backups to check progress.
Stop a running restore with heroku pg:backups:cancel.

Restoring... !
 ▸    An error occurred and the backup did not finish.
 ▸    
 ▸    waiting for restore to complete
 ▸    pg_restore finished with errors
 ▸    waiting for download to complete
 ▸    download finished with errors
 ▸    please check the source URL and ensure it is publicly accessible
 ▸    
 ▸    Run heroku pg:backups:info r018 for more details.
$ heroku pg:backups:info r018
 ›   Error: Missing required flag:
 ›     -a, --app APP  app to run command against
 ›   See more help with --help

我的 secure-file-location-url 是一个 public Google 驱动器 link,我可以在隐身浏览器中访问它 window.

正如评论中所讨论的,您的数据库转储托管在 Google 驱动器上,您提供的 link 通过 "download file" 按钮发送给查看者。

相反,您必须直接向文件提供 link。文档推荐使用 Amazon S3。

我也 运行 遇到了这个问题,我是如何通过添加 运行 Heroku CLI 命令来解决它的。格式如下: heroku pg:backups:restore '<signed url>' DATABASE_URL -a <your-application-name> 从字面上看,把 DATABASE_URL 放在那里,它会从你的环境变量中读取它。如果您尝试输入 postgress 地址,它将失败。此外,应用程序必须是最后添加到此命令的东西,这里的顺序很重要。