有没有比 Taps 更快的方法从 Heroku 提取生产数据?
我经常需要克隆生产数据来调查错误。即使数据库大小很小,heroku db:pull (taps) 也需要 5 分钟以上,并且失败的可能性很高。 是否有替代方法来提取数据库?
替代流程/文章的库也将受到赞赏。
I often need to clone production data to investigate bugs. Even with a trivial database size heroku db:pull (taps) takes 5+ minutes and seems to have a high chance of failing. Is there an alternative method to pull the database?
Libraries for alternative processes / articles would also be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
查看 pgbackups。它取代了 Heroku 的捆绑命令,并且会给你一个相当于 mysqldump 的 postgres 命令。这比大型数据集的 Taps 文明得多。
将创建一个转储文件并存储它。要下载转储文件,您需要使用获得的 url
,这将返回一个可以从中下载转储的 url。如果您愿意,您可以将其粘贴到 Firefox 中,或者像他们建议的那样使用curl/wget。使用 pg_restore 将转储文件加载到数据库中,如文档中所述:
pg_restore:连接到数据库进行恢复
Check out pgbackups. It has replaced the Heroku bundle command and will give you a the postgres equivalent of mysqldump. This is far more civilized than Taps for large datasets.
Will create a dumpfile and store it. To download the dumpfile you need the url which you get with
That will return an url from which you can download your dump. You can paste it into Firefox if you want or use curl/wget like they suggest. The use pg_restore to load the dump file into your database as they say in the docs:
pg_restore: connecting to database for restore
我创建了一个 shell 脚本来自动执行此过程(基于 Mike Williamson 的回答)。
https://gist.github.com/921535
I created a shell script that automates this process (based on Mike Williamson's answer).
https://gist.github.com/921535
Mike 是正确的 - PGBackups 就是执行此操作的方法。当您使用 PGBackups 创建备份时,您可以访问标准 pg_dump 文件。 这里是开发中心 PGBackups 文章的相关部分。
Mike's correct - PGBackups is the way to do this. When you create a backup with PGBackups, you get access to a standard pg_dump file. Here's the relevant section of the Dev Center PGBackups article.
这篇文章现在已经很老了。
目前最新、最简单的方法是使用 Heroku 的 pg:pull /pg:推
This post is quite old right now.
The newest and easiest method right now is using Heroku's pg:pull/pg:push
对 Jack 的 脚本的更新,其中 Heroku 的建议 截至 2015 年 1 月。
第一部分是由于在不同的计算机上运行,因此我的 Postgres dbs 有不同的名称。
An update to Jack's script, with Heroku's recommendation as of Jan 2015.
The first part is due to running on different computers, hence my Postgres dbs has different names.
这是我编写的一个脚本,它利用 Lomefin 提到的 pg:pull 来从 Heroku 中拉取数据库并用它替换本地数据库
:克隆到新数据库时,您的工作不会被中断(仅重命名数据库一次,这需要几分之一秒的时间)。当然,可以根据您的喜好轻松定制脚本。
Here is a script I wrote that utilizes
pg:pull
, as mentioned by Lomefin, to pull down a db from Heroku and replace a local one with it:Since
pg:pull
clones to a new database, your work will not be interrupted (only once it renames the db, which takes a fraction of a second). The script can, of course, be easily customized to your liking.