无法使用AWS导入Heroku Postgres

时间:2019-07-17 08:11:44

标签: postgresql amazon-web-services heroku

C:\Users\uc256592\Downloads\git\gcesalem>heroku pg:backups:restore "https://smartnava.s3.amazonaws.com/backup_1.dump?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA6GYJD6AIKNXQOCXK%2F20190716%2Fus-east-2%2Fs3%2Faws4_request&X-Amz-Date=20190716T150317Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=2f22c6d714e115f615fce9e3849f4517b2cc95b350f6dc7786a79be6804fba4c"
     

DATABASE_URL        !警告:破坏性行动        !此命令将影响应用程序gcesalem        !要继续,请键入gcesalem或使用--confirm gcesalem重新运行此命令

> gcesalem
Starting restore of https://smartnava.s3.amazonaws.com/backup_1.dump?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA6GYJD6AIKNXQOCXK%2F20190716%2Fus-east-2%2Fs3%2Faws4_request&X-Amz-Date=20190716T150317Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=2f22c6d714e115f615fce9e3849f4517b2cc95b350f6dc7786a79be6804fba4c
     

到postgresql-round-71929 ...完成

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 r006 for more details.

信息

 C:\Users\uc256592\Downloads\git\gcesalem>heroku pg:backups:info r006
 === Backup r006
 Database:         BACKUP
 Started at:       2019-07-16 15:34:40 +0000
 Finished at:      2019-07-16 15:34:40 +0000
 Status:           Failed
 Type:             Manual
 Backup Size:      0.00B (0% compression)

 === Backup Logs
 2019-07-16 15:34:40 +0000 pg_restore: [archiver] did not find magic string in file header
 2019-07-16 15:34:40 +0000 waiting for restore to complete
 2019-07-16 15:34:40 +0000 pg_restore finished with errors
 2019-07-16 15:34:40 +0000 waiting for download to complete
 2019-07-16 15:34:40 +0000 download finished with errors
 2019-07-16 15:34:40 +0000 please check the source URL and ensure it is publicly accessible- - 

1 个答案:

答案 0 :(得分:1)

您可以导出本地数据库的副本,然后将其导入到Heroku。

  

要从本地数据库导出,

pg_dump <DATABASE_NAME> > <FILENAME>.sql 

这将要求您输入数据库密码。但是在Windows中,这将询问用户密码,因为默认用户名是系统用户名。为此,您必须指定您的用户名

pg_dump -U <USER_NAME> <DATABASE_NAME> > <FILENAME>.sql 

对于您的情况,命令将如下所示:

pg_dump -U postgres gce > gce.sql 
  

导出本地数据库后,您可以将其直接上传到heruko。

heroku pg:psql --app <APP_NAME> < gce.sql