首先我试图获取公共网址:
justas@justas-Lenovo-M490s ~/dev/myrubyblog $ heroku pg:backups public-url
The following URL will expire at 2016-10-06 10:04:52 +0000:
"https://xfrtu.s3.amazonaws.com/c9d6480e-da41-4783-b54e-027ff267d19e/2016-10-05T20%3A06%3A08Z/67d4ad22-8cc7-4b86-aee9-7c2e648bb5aa?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJCSJJKP7D4MYHIDQ%2F20161006%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20161006T090452Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=d5807003573a49d241caf0e6805e4b770e6b25c861a7ccca0772f282167a4bed"
我可以使用浏览器免费下载。但如果我尝试导入它:
justas@justas-Lenovo-M490s ~/dev/myrubyblog $ heroku pg:backups restore DATABASE "URL described above"
! Unknown database: URL described above. Valid options are: DATABASE_URL
我也尝试过使用DATABASE_URL,但结果相同。
justas@justas-Lenovo-M490s ~/dev/myrubyblog $ heroku pg:backups capture
Use Ctrl-C at any time to stop monitoring progress; the backup
will continue running. Use heroku pg:backups info to check progress.
Stop a running backup with heroku pg:backups cancel.
DATABASE ---backup---> b002
Backup completed
如果我列出所有备份,我可以清楚地看到它已创建:
justas@justas-Lenovo-M490s ~/dev/myrubyblog $ heroku pg:backups
=== Backups
ID Backup Time Status Size Database
---- ------------------------- ----------------------------------- ------ --------
b002 2016-10-06 09:09:15 +0000 Completed 2016-10-06 09:09:17 +0000 7.45kB DATABASE
b001 2016-10-05 20:06:08 +0000 Completed 2016-10-05 20:06:09 +0000 7.45kB DATABASE
=== Restores
No restores found. Use `heroku pg:backups restore` to restore a backup
=== Copies
No copies found. Use `heroku pg:copy` to copy a database to another
但它不会让我恢复/导入它:
justas@justas-Lenovo-M490s ~/dev/myrubyblog $ heroku pg:backups restore DATABASE b002
! Unknown database: b002. Valid options are: DATABASE_URL
使用DATABASE_URL而不是DATABASE的结果相同。我真的需要你的帮助。希望我能给你足够的信息。
答案 0 :(得分:0)
在heroku中导入.sql文件
heroku pg:psql --app YOUR_APP_NAME_HERE < updates.sql
从另一个heroku应用数据库导入。
heroku pg:backups restore `heroku pg:backups public-url -a YOUR_PRODUCTION_APP_NAME` YOUR_STAGING_DATABASE_NAME --app YOUR_STAGING_APP_NAME --confirm YOUR_STAGING_APP_NAME
类似的问题:How can I import a .sql file into my Heroku postgres database?