将数据库从一个heroku应用更快地转移到另一个应用

编程入门 行业动态 更新时间:2024-10-26 20:27:43
本文介绍了将数据库从一个heroku应用更快地转移到另一个应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

目前我正在做一个 heroku db:pull 到我的本地机器,然后 heroku db:push --app testapp 但这会变得非常耗时。我有一些种子数据,但它不像使用我的真实世界数据测试那么准确。由于它们都存储在相邻的AWS云上,所以必须有更快的方式来移动数据?

我想过使用一个heroku包,但我注意到了animate命令不见了?

捆绑:animate< bundle> #将一个包动画成一个新的应用程序

解决方案

在Rails应用程序的暂存,测试和生产环境之间迁移数据库。而 heroku db:pull / push 非常缓慢。到目前为止,我发现的最好方法是使用 Heroku PG备份加载项和它是免费的。我遵循以下步骤将生产数据库迁移到登台服务器:

$ b

1)为生产应用程序db创建备份

heroku pg:备份捕获--app production-app

这将从主数据库(通常是database.yml中的生产数据库)生成b001备份文件。b)查看所有备份(可选)

heroku pg:备份--app production-app

3)现在使用pg:backups restore命令从生产服务器上的最后一个备份文件填充登台服务器数据库

heroku pg:备份恢复$(备份恢复公共网址--app生产应用程序)DATABASE_URL --app staging-app

请记住,还原是一种破坏性操作,它会在将其替换为备份文件的内容之前删除现有数据。

Is there a faster way to transfer my production database to a test app?

Currently I'm doing a heroku db:pull to my local machine then heroku db:push --app testapp but this is becoming time consuming. I have some seed data but it is not nearly as accurate as simply testing with my real-world data. And since they're both stored on a neighboring AWS cloud, there must be a faster way to move the data?

I thought about using a heroku bundle, but I noticed the animate command is gone?

bundles:animate <bundle> # animate a bundle into a new app

解决方案

It's quite common to migrate databases between staging, testing and production environments for Rails Apps. And heroku db:pull/push is painfully slow. The best way I have found so far is using Heroku PG Backups add-on and it's free. I followed following steps to migrate production database to staging server:

1) Create the backup for the production-app db

heroku pg:backups capture --app production-app

This will generate b001 backup file from the main database (usually production db in database.yml)

2) To view all the backups (OPTIONAL)

heroku pg:backups --app production-app

3) Now use the pg:backups restore command to populate staging server database from the last backup file on production server

heroku pg:backups restore $(heroku pg:backups public-url --app production-app) DATABASE_URL --app staging-app

Remember that restore is a destructive operation, it will delete existing data before replacing it with the contents of the backup file.

更多推荐

将数据库从一个heroku应用更快地转移到另一个应用

本文发布于:2023-10-20 03:22:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1509695.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:更快   数据库   转移到   heroku

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!