I have deployed Rails app to Heroku. App uses PostgreSQL for data management. It works fine locally. I am searching for a way to push my local PostgreSQL database to the Heroku database.
heroku pg:push command doesn't work for me. Complains about lack of local psql, which is there. So I have decided to use pgbackups add-on for this purpose. I have run pg_dump locally to create a database dump and put it into the public Dropbox folder.
When I try to pull it from heroku I get the following error:
heroku pgbackups:restore DATABASE "http://file.dump"
! An error occurred and your restore did not finish.
! Please run 'heroku logs --ps pgbackups' for details.
The problem is that heroku logs --ps pgbackups gives me nothing. I don't see any pgbackups associated logs in the Heroku log listing.
Am I doing something wrong? Do I need to turn on heroku add-on logs somehow?
P.S. I am able to run heroku pgbackups:capture and heroku pgbackups:restore, but I don't see any logs either.
Related
I am learning ruby on rails and heroku.
I have some questions.
Could somebody help me?
After running heroku create, the terminal is somehow connected to the repository/project in heroku. After that the developer can see logs, access database, ect. But, how can I access via terminal my completed project,which is online already, in heroku without creating the same apps and upload it again to heroku?
How can access my pg database in heroku or offline?
I saw this and try to run heroku pg:psql. it gives me hidden-atoll-4790::DATABASE=> help I try \? to see pg command but I cannot use it.
I saw this link to see pg db offline. But why cannot I access /var/lib/postgresql/9.3/main directory ? it is said that I don't have permission eventhough my account is administrator account.
1.Run heroku run rails console
Run
$ heroku apps # to see all apps created by your account
$ heroku open # to open you current project in browser (run it form root of your project)
$ heroku pg:psql DATABASE_URL # to gain access to heroku postgresql terminal, here you can run SQL queries
Refer to
CLI and Heroku PG for more info
I recently started collaborating in a project on Heroku using Ruby on Rails. I was added as a collaborator and added the remote to my environment. After some development, I pushed some changes and had no problems:
$ git push staging
Where staging is the name of my remote.
Later, when trying to run "rake test" on Heroku, I recieved an error:
$heroku run rake test --app staging
Running `rake test` attached to terminal... failed
! You do not have access to the app staging.
Which is odd, as I was perfectly able to push my own changes. I checked the Heroku dashboard and saw that my push was logged there. I then tried to view the logs using the console, and the same problem occured.
$ heroku logs --app staging
! You do not have access to the app staging.
Finally, I tried to access the console, but it failed as well.
$ heroku run rails console --app staging
Running `rails console` attached to terminal... failed
! You do not have access to the app staging.
At this point I updated my Heroku toolbelt installation, and used "heroku auth" to verify that my email was showing up, but the error persists. I'm currently contacting Heroku support but I'm hoping someone with a similar issue could aid me in parallel.
Thanks!
So just in case anyone is having a similar problem, this occurs because I was mixing the name of my Heroku Apps with the name of my git remotes. So when I was calling --app staging (the name of my remote), I should have been using the actual name of the app, as found in Heroku.
Be sure to run heroku login before using Heroku toolbelt commands for the first time. It will not tell you that you have not signed in before.
This happen also when you haven't added heroku git remote repository.
You can add it with this command:
git remote add heroku https://git.heroku.com/<your project>.git
You can also type
heroku git:remote -a AppName
I had the same problem because I had created multiple remotes on heroku (e.g. a remote called "staging" for staging, and the default remote "heroku" for prod).
Solution
Use these two options to let heroku know which app and remote you're referring to:
-a your_app_name, and
--remote name_of_remote
Examples
For example, for the remote called staging:
heroku run env -a your_app_name --remote staging
or like this for the production remote:
heroku run env -a your_app_name --remote heroku
Extra Info
The above code runs the simple command env, but you can replace that with whatever commands you want to run on heroku.
Replace the name of the remote. By default, heroku creates one remote called heroku, which is typically the production remote. You can get your remotes with the command: git remote.
This was caused of your ssh key is no more permited to access. Make sure your ssh key is same. You can also regenarate your ssh key and add this to heroku.
You can also run:
heroku run rake test --remote staging
Not sure what happens under the hood, but locally the CLI tool figures out which app you mean based on your git remote.
I had the same problem in my case I was not pushing from master so I had to use this:
git push heroku :main
I had the same problem. It was cause I was not login in Heroku.
First I type:
heroku login
then i type:
heroku git:remote -a restserver-node-jngs
and it works.
I hope it be helpfull for someone.
I often do heroku db:pull and it works great.
I have created a staging app, to review code changes on Heroku before deploying to the production app.
I wonder though how I push db data specifically to the staging app?
Will the follwing work? heroku db:push -a my-staging-app-name
heroku db:push -a my-staging-app-name
will only push your local data to heroku. but it has some problems
I suggest you to push production db directly to staging server
For that you need to get the URL from production and run following command.
heroku pgbackups:restore DATABASE 'db_dump_url' -a my-staging-app-name
I tried to use heroku-valkyrie to transfer my local data to heroku databse.
https://github.com/ddollar/heroku-valkyrie
I installed the plugin:
heroku plugins:install http://github.com/ddollar/heroku-valkyrie.git
Installing heroku-valkyrie... done
and wanted to transfer data:
heroku db:transfer sqlite://db/development.sqlite3 postgres://my-apps-database-url/
but received this error message:
! `db:transfer` is not a heroku command.
! See `heroku help` for a list of available commands.
How can I use db:transfer as a heroku command?
According to Heroku documentation, you will have to export your local database as a dump file by using the pg dump tool and import the file using command.,
heroku pgbackups:restore DATABASE 'https://s3.amazonaws.com/me/items/3H0q/mydb.dump'
Check for complete documentation here
Try running heroku plugins:install https://github.com/ddollar/heroku-pg-transfer first.
Then the command will be pg:transfer, not db:transfer.
However, you may run into issues since you're transferring from an sqlite database and this command only transfers from postgre.
I had a working Active Admin app working on my local server, but after pushing to Heroku all my database tables are empty. I tried running heroku run rake db:migrate and then heroku restart but these both accomplished nothing. The tables are there, but they are empty.
Thanks!
If you want to have your Heroku app have the same database as local then you would you need to push your local database via heroku db:push to Heroku. This will replace the contents of the tables on Heroku with your local copy so use it carefully.
EDIT: heroku db:push is now heroku pg:push, the former is deprecated.