简体   繁体   English

如何将数据库上传到Heroku

[英]How can I upload a DB to Heroku

I have a shared heroku app, now I wan't to create a test app also in heroku with the same code, so I've created a new app, ok, the thing is that for the app to work it needs a database, so I'm trying to upload my local DB but don't know how to. 我有一个共享的heroku应用程序,现在我不想在heroku中使用相同的代码创建一个测试应用程序,所以我创建了一个新的应用程序,好吧,问题是,对于应用程序来说它需要一个数据库,所以我试图上传我的本地数据库,但不知道如何。

Can anyone tell me what do I have to type in my command line so I can get my local DB uploaded? 任何人都可以告诉我,我有什么要输入我的命令行,以便我可以上传我的本地数据库?

Thanks 谢谢

Ps: The app uses Django Ps:该应用程序使用Django

You should restore database from a url, see heroku import doc : 您应该从URL恢复数据库,请参阅heroku导入文档

heroku pgbackups:restore DATABASE 'http://f.cl.l...3z18/mydb.dump'

Edit: 编辑:

The pgbackups addon has been deprecated . pgbackups插件已被弃用 The process is now built in to the CLI tools. 现在,该过程内置于CLI工具中。 More details here . 更多细节在这里 The new method looks like this: 新方法如下所示:

heroku pg:backups restore 'http://f.cl.l...3z18/mydb.dump' DATABASE

@danihp's answer is a good one - it is exactly what the documentation recommends . @ danihp的答案很好 - 这正是文档推荐的内容

BUT it requires posting the file in some awkward place like S3. 但它需要将文件发布在像S3这样尴尬的地方。

However, as the OP asks - how can we do this without having to push the database dump to someplace awkward like S3? 然而,正如OP所要求的那样 - 我们怎样才能做到这一点而不必将数据库转储推到像S3那样尴尬的地方?

The most convenient answer I've been able to find (mentioned in @danihp's comment) is to use dropbox. 我能找到的最方便的答案(在@ danihp的评论中提到)是使用dropbox。

In detail (not described in danihp's comment): 详细(danihp的评论中没有描述):

Simply 只是

  • put the dump file into your "Public" dropbox folder 将转储文件放入“公共”保管箱文件夹中
  • right click and choose "Copy Public Link" 右键单击并选择“复制公共链接”
  • Paste the url you just copied into the command: 将刚刚复制的url粘贴到命令中:

     heroku pgbackups:restore DATABASE_URL "<paste link here>" 

If you don't want to put the dump file in your "Public" folder, then you need to do one more step. 如果您不想将转储文件放在“公共”文件夹中,则需要再执行一个步骤。

You need to 你需要

  • put is in some other dropbox folder put是在其他一些dropbox文件夹中
  • right click, and chose "share Dropbox Link" 右键单击,然后选择“共享Dropbox Link”
  • paste the link into a browser, which will show you the dump file page 将链接粘贴到浏览器中,该浏览器将显示转储文件页面
  • right click the "download" button and copy the URL. 右键单击“下载”按钮并复制URL。
  • paste that URL into the command. 将该 URL粘贴到命令中。

HTH. HTH。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM