为什么我的本地PostgreSQL数据库推送到我的Heroku Postgres不起作用?



我创建了一个私有AWS S3存储桶并将其放入我的数据库中。我用以下命令创建的转储文件:

pg_dump -Fc --no-acl --no-owner -h localhost -U myuser -d mydatabase > mydatabase.dump
然后,我创建了一个带签名的url:
aws s3 presign s3://fivbackup/strapifivfr.pgsql --expires-in 604800 --region eu-west-3

我可以按照签名的URL下载文件。

当我尝试这个命令时,我得到一个错误:

heroku pg:backups:restore 'RAW_SIGNED_URL' -a fivteam2 DATABASE_URL

//
Restoring... !
! An error occurred and the backup did not finish.
!
! pg_restore: error: could not read from input file: end of file
! 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
heroku pg:backups:info r013:
=== Backup r013
Database: BACKUP
Started at: 2021-08-27 15:17:09 +0000
Finished at: 2021-08-27 15:17:10 +0000
Status: Failed
Type: Manual
Backup Size: 0.00B (0% compression)
=== Backup Logs
2021-08-27 15:17:10 +0000 2021/08/27 15:17:10 aborting: could not write to output stream: Expected HTTP Status 200, received: "400 Bad Request"
2021-08-27 15:17:10 +0000 waiting for restore to complete
2021-08-27 15:17:10 +0000 pg_restore: error: could not read from input file: end of file
2021-08-27 15:17:10 +0000 pg_restore finished with errors
2021-08-27 15:17:10 +0000 waiting for download to complete
2021-08-27 15:17:10 +0000 download finished with errors
2021-08-27 15:17:10 +0000 please check the source URL and ensure it is publicly accessible

我还尝试了命令heroku pug:push mydatabase DATABASE_URL -a myapp,但无法设置PGUSER变量(无法识别的术语)。Ps:我在windows上

更新:我在公共模式下推送了我的数据库,而不是使用一个指定的url(不是最好的选择,但我会继续挖掘),但下面的这个可能会帮助一些像我这样的新手:

1:我遇到的一个问题是转储文件格式无效。我试图恢复我的转储文件在TablePlus测试格式,它没有工作。因此,我没有使用CLI生成转储,而是使用TablePlus并选择了自定义格式选项。然后我通过在TablePlus中恢复它来测试这次文件格式是否被接受:它工作了!

2:我想我误解了我在AWS S3中的授权设置,我仍然很困惑公共和私有桶公共和私有文件

3:我意识到我的VSCode控制台改变了我粘贴成字符串的url,所以我使用了桌面命令行。

最新更新