heroku DATABASE_URL - heroku

On heroku, how to get the whole value of DATABASE_URL ?
When I issue a
heroku config --app APP_NAME
I get several config parameters but the DATABASE_URL is not entirely visible
DATABASE_URL => postgres://ruhej...s.com/oeuhenchej
Any idea ?

$ heroku config --app APP_NAME
(The Heroku toolbelt has been updated since the question was asked; the command now shows the entire DATABASE_URL.)

$ heroku pg:credentials:url YOUR_DATABASE_NAME
Gives you all the informations needed (url, port, dbname, user, password):
Connection information for default credential.
Connection info string:
"dbname=xxxxxxxxxxxxxx host=yyyyyyyyyyyyyyyyyyyyyyyyyyy.amazonaws.com port=5432 user=zzzzzzzzzzzzzz password=************* sslmode=require"
Connection URL:
postgres://zzzzzzzzzzzzzz:*************#yyyyyyyyyyyyyyyyyyyyyyyyyyy.amazonaws.com:5432/xxxxxxxxxxxxxx

This may seem really basic but your heroku APP_NAME is app_name.heroku.com. You can find that by logging into heroku.com and looking in your account. In order to get your app config variables you simply type into the console:
heroku config --app APP_NAME

To get the full database URL, use config:get from the Heroku CLI;
heroku config:get DATABASE_URL -a my-app-name

To get PostgreSQL dump file from heroku :-
heroku pg:backups:capture
heroku pg:backups
it shows all the backups
heroku pg:backups:url BackupID

Related

Set config variables in heroku using `cat example.file`

I'm following this tutorial (best answer) SSH tunneling from Heroku
And they say to set some heroku config vars like MY_VAR=cat my.file to save the contents of the file to heroku. The problem is, I don't think this method works anymore. I'm looking for help on either how to do this the right way, or how to emulate this. Here is the traceback.
(bosnetvenv) michael#michael-VivoBook-ASUSLaptop-MJ401TA:~/projects/znet/bosnet$ heroku config:set ZEAL_FULL_NODE_PRIVATE_KEY=`cat ~/.ssh/heroku_id_rsa`
› Warning: heroku update available from 7.35.0 to 7.38.1.
▸ RSA is invalid. Must be in the format FOO=bar.
(bosnetvenv) michael#michael-VivoBook-ASUSLaptop-MJ401TA:~/projects/znet/bosnet$ heroku config
› Warning: heroku update available from 7.35.0 to 7.38.1.
=== zealchain Config Vars
DATABASE_URL: REDACTED
IS_PRODUCTION: True
ZEAL_FULL_NODE_PRIVATE_KEY:
(bosnetvenv) michael#michael-VivoBook-ASUSLaptop-MJ401TA:~/projects/znet/bosnet$ heroku config:set ZEAL_FULL_NODE_PUBLIC_KEY=`cat ~/.ssh/heroku_id_rsa.pub`
› Warning: heroku update available from 7.35.0 to 7.38.1.
▸ REDACTED
▸ is invalid. Must be in the format FOO=bar.
Thank in advance.
needed quotes.
heroku config:set "MY_VAR=test.file"

Heroku Kafka certificates

According to the documentation, Heroku passes KAFKA_TRUSTED_CERT, KAFKA_CLIENT_CERT and KAFKA_CLIENT_CERT_KEY directly into my heroku applications. In consequence, only applications running on heroku can access Heroku Kafka? I would like to access it directly from my home workstation but i dont know how to get the ENVs
You can run either heroku config --app your_application_name to get all variables, or run heroku config:get KAFKA_TRUSTED_CERT --app your_application_name to just get one specific variable.
You can also login to Heroku dashboard and find all variables there in "Settings" section of your app.

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.

Heroku toolbelt command requires app-name

How do you specify the app you want when you log in to Heroku from the command line?
I was trying to check the logs so when I first logged in I tried:
Heroku logs
this then told me:
! No app specified.
! Run this command from an app folder or specify which app to use with --app <app name>
I then tried:
heroku --app my-appname
but i get:
`--app` is not a heroku command.
I have tried all combinations.
You still need to include the command:
heroku logs --app app-name
You can also use -a instead of --app:
heroku logs -a app-name
Another option is to associate your (git) project to Heroku. From heroku open - no app specified:
$ cd app-dir
$ heroku git:remote -a app-name
$ heroku logs
Try this:
heroku git:remote -a [app_name]
This should allow you to call commands without having to specify which app you want them to be called on.
You could try adding --app app-name after you sentence.
Example: $ heroku domains:add your-domain --app app-name
Heroku CLI automatically detects the app name by scanning the git remotes for the current working copy.
If you're not in the app's local git clone, you need to specify the app name:
heroku logs --app app-name
or
heroku logs -a app-name
or by specifying the remote name:
heroku logs --remote production
You can reference this part of the Heroku documentation:
https://devcenter.heroku.com/articles/using-the-cli#app-commands
From my tests the Heroku CLI will infer the app from the current Git remote.
So to change to the "test" app:
git config heroku.remote test
And to come back to the default "heroku" application, which is probably your production app:
git config heroku.remote heroku
Not sure this is a good idea though...
For future solution seekers-
The error says a possible solution.
Run this command from an app folder
cd to the app directory root, then run your desired command.

How can I access memcache on Heroku via command line

How can I access memcache on Heroku via command, I just want to look up some key and delete it.
Thanks
heroku run console --app your-app-name
for Cedar, or
heroku console --app your-app-name
for Bamboo and Aspen. Then
m = Memcached.new

Resources