Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

transfer db from one heroku app to another faster

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  
like image 496
holden Avatar asked Oct 03 '10 15:10

holden


People also ask

How do I push my Heroku database?

The command looks like this: $ heroku pg:push mylocaldb HEROKU_POSTGRESQL_MAGENTA --app sushi This command will take the local database “mylocaldb” and push it to the database at DATABASE_URL on the app “sushi”. In order to prevent accidental data overwrites and loss, the remote database must be empty.

How do I transfer my Heroku app?

In Dashboard, click the Team name of the Team you would like to transfer apps into. Click the Transfer apps button. Use the select box to select apps from your personal apps list, or another Team's apps list. Select the apps you would like to transfer to the Team.


1 Answers

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.

like image 181
Zeeshan Avatar answered Oct 02 '22 15:10

Zeeshan