Transfer heroku database from one bamboo app to another cedar app - ruby

Is there a faster way to transfer database on one app to another, without using capture and restore process which is taking 3hrs in my case.
We are trying to move to Cedar app and can't afford a 3hrs downtime.
Is it possible to:
1. create a follower on current prod app
2. allow to catch up.
3. maintenace on
4. unfollow the follower on current prod app that I created on step 1
5. Promote that follower to another app.
6. maintenance off
Similar to this link: https://devcenter.heroku.com/articles/fast-database-changeovers
but trying to promote it to another app.
Is it possible?
Regards

If you are on one of the production plans for your database, you're in luck. There is a secret flag that you can use. It doesn't work for the dev plans, only crane and above. If your Bamboo app has a crane or better database, you can create a fork of it by grabbing the DATABASE_URL, and then running:
heroku addons:add heroku-postgresql:crane --fork="<PASTE DATABASE_URL HERE>" --app your-cedar-app
Or if you prefer, for minimal downtime using a procedure similar to our fast changeover:
heroku addons:add heroku-postgresql:crane --follow="<PASTE DATABASE_URL HERE>" --app your-cedar-app
heroku pg:wait --app your-cedar-app # let the new database boot
heroku pg:info --app your-cedar-app # Make sure it's caught up, Behind By should be =~ 0.
heroku maintenance:on --app your-cedar-app
heroku pg:unfollow HEROKU_POSTGRESQL_<color of new database> --app your-cedar-app
heroku pg:promote HEROKU_POSTGRESQL_<color of new database> --app your-cedar-app # make it the primary
heroku maintenance:off --app your-cedar-app

Related

How to back up Heroku pg database from app itself?

From a remote shell, using the Heroku toolbelt, it's pretty easy to trigger a db backup with:
heroku pg:backups:capture --app my-app
But how can I do that from a script running on the app itself? Something triggered from the heroku scheduler or manually like:
heroku run node myScript.js --app my-app
I have psql available so maybe that's an option although I don't know where to write to.
I don't see a way to do this via API here: https://devcenter.heroku.com/articles/platform-api-reference

Upgrade hobby-dev to hobby-basic on Heroku

I'm still getting my head wrapped around Heroku's plans. But I know I'm going to have around 3M rows in the db so I need to upgrade from hobby-dev to hobby-basic.
However, I can't find any documentation or help about this level of upgrade. Only docs to go from Hobby to Standard.
Do I need to create a new PG Add-On and then wipe out my hobby-dev db?
This answer assumes that you're using Heroku CLI. Any instance of "YOUR_APP_NAME" in a command should be replaced by the application name of the Heroku App you're working with.
You will also need on hand the connection URL (shown here as DATABASE_URL) of your current hobby-dev database to be upgraded.
1. Provision a new hobby-basic database:
heroku addons:create heroku-postgresql:hobby-basic -a YOUR_APP_NAME
This will output a name for the new database containing a color. You will need to refer to this later. For example:
HEROKU_POSTGRESQL_PINK_URL
2. Optionally put db into maintenance mode to ensure that no data is added to the db while it's being copied.
heroku maintenance:on --app YOUR_APP_NAME
3. Copy the existing hobby-dev db to the hobby-basic db
heroku pg:copy DATABASE_URL HEROKU_POSTGRESQL_PINK --app YOUR_APP_NAME
Heroku will now print the following message.
heroku pg:copy DATABASE_URL HEROKU_POSTGRESQL_PINK --app YOUR_APP_NAME
! WARNING: Destructive Action
! Transfering data from DATABASE_URL to HEROKU_POSTGRESQL_PINK
! This command will affect the app: YOUR_APP_NAME
! To proceed, type "YOUR_APP_NAME" or re-run this command with --confirm YOUR_APP_NAME
YOUR_APP_NAME
4. Confirm db transfer by typing the actual name of your application
YOUR_APP_NAME
5. Promote your new database
heroku pg:promote HEROKU_POSTGRESQL_PINK --app YOUR_APP_NAME
The color-based name of the database you promote should be copied from the output you got up in step 1. Do not copy and paste the line above word for word, it will not work.
6. If you put your db into maintenance mode earlier, turn it off.
heroku maintenance:off --app YOUR_APP_NAME

Copy production database to staging heroku

How can I pull my production database to my staging server on heroku?
I have two remotes, production and staging.
From the documentation it appears that I want to run heroku pg:copy COBALT GREEN --app sushi but it isn't clear what all the arguments mean. How can I copy my production database to my staging database?
First use:
heroku pg:info -a your_production_app
to retrieve the name of the environment variable that has the URL of your production db, e.g HEROKU_POSTGRESQL_WHITE_URL.
Then:
heroku pg_info -a your_staging_app
to get the same for your staging app (e.g. DATABASE_URL).
Finally:
heroku pg:copy your_production_app::HEROKU_POSTGRESQL_WHITE_URL DATABASE_URL -a your_staging_app
Just to add a clarification to the #Yoni Rabinovitch's answer.
I do not have named database so I needed to replace name with DATABASE_URL instead. It is not much intuitive to duplicate DATABASE_URL, is it?
So instead of:
heroku pg:copy your_production_app::HEROKU_POSTGRESQL_WHITE_URL DATABASE_URL -a your_staging_app
I used
heroku pg:copy your_production_app::DATABASE_URL DATABASE_URL -a your_staging_app
Hope this might help somebody.

How can I deploy to a specific app with heroku docker:release?

Using the heroku docker:release command, how can I specify which app to release to? I can't see from any documentation whether there's any switch for this purpose.
Heroku commands take their context from the directory you are in when you run them.
Go into the directory from where you did heroku create then run heroku docker:release.
If you haven't used heroku create, then you can specify the app name with the --app <APP NAME> command line parameter. for instance, if you were to release to the app named f00 you would type:
heroku docker:release --app f00

Heroku and Environments -domains are not working

I am finding that managing production and staging env's on heroku truly a painful process esp with domains, git etc.
1) I created app called htest.
2) In the htest directory I did the below:
heroku create --app htest-staging --remote staging
heroku create --app htest-production --remote production
heroku domains:add staging.mydomain.com --app htest-staging --remote staging
heroku domains:add production.mydomain.com --app htest-production --remote production
3) I committed the app and started service
git push staging master
heroku ps --app htest-staging --remote staging
3) I add domain to route53 with the cname of htest-staging.herokuapp.com
heroku info --app htest-staging
=== htest-staging
Web URL: http://htest-staging.herokuapp.com/
as expected I get web page not found.
What is even more troubling is that when I go to http://htest-staging.herokuapp.com/ I get this on the page:
Heroku | Welcome to your new app!
Refer to the documentation if you need help deploying.
My python app should have said hello world.
So..how do I resolve?

Resources