Heroku 数据库还原问题

Heroku database restore issue

已在 Whosebug 以及不同论坛上浏览过不同的解决方案。但是 none 解决了精确的问题。

As per the documentation: https://devcenter.heroku.com/articles/heroku-postgres-import-export

我使用以下命令从我的本地数据库创建了 dump 文件:

pg_dump -Fc --no-acl --no-owner -h localhost -U postgres dss_iaya>dss_iaya_db_dump1.dump

然后根据文档,上传到具有 public 访问权限的服务器 URL:https://firebasestorage.googleapis.com/v0/b/iaya-664f3.appspot.com/o/dss_iaya_db_dump1.dump?alt=media&token=06167d04-1e98-4e4b-b0e0-9d83a86dd167

现在,当我尝试使用以下命令根据其文档语法 heroku pg:backups:restore [BACKUP] [DATABASE] --app APPHeroku 上恢复时,恢复时出现 returns 错误消息。

heroku pg:backups:restore  --app heroku-postgres-*** 'https://firebasestorage.***/dss_iaya_db_dump1.dump?alt=media&token=***' 'postgres://quesu***:I***@ec2-54-***.eu-west-1.compute.amazonaws.com:5432/d3n***k0' 

I have used *** for security purpose only, as can not mention full credentials. But I believe one can understand the whole syntax.

当我在新创建的本地数据库上恢复相同的 .dump 文件时,它可以正常工作并且 creates/restores 整个数据库包含表和数据。

刚刚找到解决方案,实际上在我的案例中有两处错误。

一、上传的.dump文件没有被heroku.

处理好readable/usable

二、heroku postgresql DB完整URL不需要提供。

So, the right way that worked for me was that the uploaded file should be accessible without any token and also without any virtual/indirect path, etc. The URL to the file should point to the file directly. In my questioned problem, I was using firebase to host my DB file temporarily to do the heroku operation. And firebase was not giving direct URL to the uploaded physical file.

heroku pg:backups:restore  --app heroku-postgres-f3*** 'https://www.h***.com/dss_iaya_db_dump2.dump' DATABASE_URL

输入此命令后,系统要求我重新输入 heroku 应用程序名称以确认操作。完成后,一切都很顺利。

在日志中您看到转储大小:0 字节。您还可以看到 aborting403, 所以如果你检查你的文件:https://llfirebasestorage.googleapis.com/vo/b/iaya-664f3.appspot.com/0/dss_iaya_db_dump1.dump?a1t=media

你得到:

404. That’s an error.

The requested URL /vo/b/iaya-664f3.appspot.com/0/dss_iaya_db_dump1.dump was not found on

this server. That’s all we know.