Heroku将数据库从一个应用程序转移到另一个应用程序 [英] Heroku transfer db from one app to another
问题描述
我需要将数据库从app_1转移到app_2
I need to transfer db from app_1 to app_2
我在app_1上创建了备份
I created backup on app_1
然后运行:
heroku pg:backups恢复HEROKU_POSTGRESQL_COLOR --app app_2 heroku pgbackups:url --app app_1
heroku pg:backups restore HEROKU_POSTGRESQL_COLOR --app app_2 heroku pgbackups:url --app app_1
HEROKU_POSTGRESQL_COLOR = app_2的数据库URL
HEROKU_POSTGRESQL_COLOR = database URL for app_2
然后我得到:
! `pg:backups` is not a heroku command.
! Perhaps you meant `pgbackups`.
! See `heroku help` for a list of available commands.
所以我跑了:
heroku pgbackups :restore HEROKU_POSTGRESQL_COLOR --app app_2 heroku pgbackups:url --app app_1
heroku pgbackups:restore HEROKU_POSTGRESQL_COLOR --app app_2 heroku pgbackups:url --app app_1
然后我得到以下信息:
! WARNING: Destructive Action
! This command will affect the app: app_2
! To proceed, type "app_2" or re-run this command with --confirm app_2
重新运行此命令,所以我确认了
So I confirmed with:
> app_2
! Please add the pgbackups addon first via:
! heroku addons:add pgbackups
然后我跑了: heroku addons:add pgbackups --app app_2
Adding pgbackups on app_2... failed
! Add-on plan not found.
是否可以解决此问题?任何帮助将不胜感激!
Is there a way around this issue? any help would be greatly appreciated!
*解决方案*
我最终给Heroku发了电子邮件,他们建议我需要 heroku更新; heroku plugins:update
,但是 heroku update
仅对heroku工具带可用,并且我安装了gem。
I ended up emailing Heroku, they advised that I need to heroku update; heroku plugins:update
but heroku update
is only available to heroku toolbelt only and I had the gem installed.
解决方案:
安装Heroku工具带这里
Install Heroku toolbelt here
然后卸载gem:
gem uninstall heroku --all
运行以下命令获取版本,它应该输出 heroku-toolbelt
(而不是gem),更多信息此处
run the following to get the version and it should output heroku-toolbelt
, instead of the gem, more info here
$ heroku --version
heroku-toolbelt/2.39.0 (x86_64-darwin10.8.0) ruby/1.9.3
要通过以下方式复制数据库:
To copy the databases over:
heroku pg:backups restore `heroku pgbackups:url --app app_1` HEROKU_POSTGRESQL_COLOR --app app_2
但更好的是,您可以直接从一个数据库复制到另一个数据库而无需备份:
But even better—you can copy directly from one database to another without needing the backup:
假设app_2数据库的URL为: HEROKU_POSTGRESQL_GOLD
Assuming app_2 database url is: HEROKU_POSTGRESQL_GOLD
heroku pg:copy app_1::DATABASE_URL GOLD -a app_2
这会将主数据库从app_1复制到app_2上的GOLd数据库
That will copy the main database from app_1 to the GOLd database on app_2
推荐答案
它仅需1条命令即可将数据库从一个应用程序复制到另一个应用程序,而无需备份:
its only 1 command to copy database from app to app now you don't have to backup:
heroku pg:copy app_name_to_copy_from::database_color_to_copy_from database_color_to_copy_to --app app_name_to_copy_to
检查这里
这篇关于Heroku将数据库从一个应用程序转移到另一个应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!