Heroku DB部署

tal*_*oaj 5 heroku

我正在尝试第一次Heroku部署,遇到了麻烦

heroku pg:backups:restore "https://s3.us-east-2.amazonaws.com/myusername/POSTGRESQL.dump" 
                          DATABASE_URL --app MyAppName
Run Code Online (Sandbox Code Playgroud)

我收到错误

 !    An error occurred and the backup did not finish.
 !
 !    pg_restore: [archiver] did not find magic string in file header
 !    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 r006 for more details.
Run Code Online (Sandbox Code Playgroud)

有时错误是:

Starting restore of https://s3.us-east-2.amazonaws.com/talXXXXXXXX to postgresql-XXXXXXXXX... done

Use Ctrl-C at any time to stop monitoring progress; the ba
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 publicl
 !
 !    Run heroku pg:backups:info r015 for more details.
Run Code Online (Sandbox Code Playgroud)

我已经从各种浏览器中确认该网址可供公众使用,并且可以下载该文件。我按照Windows的建议在URL周围使用双引号,这是我做错了什么?

EGS*_*EGS 7

我面临同样的问题。结果是我的转储文件有问题。我没有正确压缩它。

--format=c选择 custom 作为格式输出(与 相同-Fc)。它默认压缩文件,但这还不够,所以我也使用了--compress标志。

这个标志告诉压缩的级别;它从 0(较轻)到 9(较重)。

我用了 9,以防万一,我的命令最终就是这样

pg_dump --format=c --compress=9 --no-acl --no-owner -h THE_HOST -U YOUR_USER THE_DATABASE > YOUR_FILE.dump
Run Code Online (Sandbox Code Playgroud)

它奏效了。

  • 只是想通过首先使用以下命令创建转储文件来确认这对我有用:`pg_dump --format=c --compress=9 -U postgres myapp_production > pg_15_aug_18.sql` 然后使用`heroku pg:backups:restore 进行还原mysite.org/uploads/tmp/pg_15_aug_18.sql" DATABASE_URL` (2认同)

tal*_*oaj 1

最后我不知道如何导入到 Heroku,因为他们宣传可以在https://devcenter.heroku.com/articles/heroku-postgres-import-export#import上完成

因此,我使用了 DBeaver 等数据库连接客户端,将数据库转储转换为 SQL 脚本,并手动运行该脚本来导入数据。

:(