I recently made a mistake by rolling back my database too far on my localhost and removed all the data from within the databases I've had. I did migrate the databases so they would return but they still were cleaned out.
Asking around what to do next, I was told that I should backup the database on Heroku (which has all the current information) and pull it onto my localhost. If this is the correct action to take, then I am still facing a problem. When I type:
heroku pg:pull DATABASE_URL mylocaldb --app (my_app_name) it returns an error of:
sh: createdb: command not found
!
! Unable to create new local database. Ensure your local Postgres is
working and try again.
I do not have the best understanding of databases as I am newer; however, I have downloaded sql on my local machine. All of the commands I input are in the regular console and not the psql terminal.
If anyone has any knowledge or can help me, I would greatly appreciate it. Thank you so much!
Joe
Edit: If you do have another method/solution, please let me know. I cannot update my application until I have this done so I do not lose my information.
I would try using backup/restore:
heroku pg:backups --app MYAPPNAME capture
curl -o latest.dump `heroku pg:backups --app MYAPPNAME public-url`
as (almost) documented at
https://devcenter.heroku.com/articles/heroku-postgres-import-export
Note the strange placement of --app MYAPPNAME. It needs to go immediately after the heroku sub-command and before any other arguments.
Related
I am new to Heroku and I keep getting the above error - everything looks good to go when I deploy in heroku, connect to my github repo etc.. but I keep getting this error.
Its a node/express app and works exactly as I'd like locally but it won't deploy. Any help would be appreciated.
For getting logs of particular heroku app, use:
heroku logs --app=app_name
For example: your app name is 'chatapp'
heroku logs -app=chatapp
just run the command with the --app flag, followed by the app name.
I like how the --app flag is "mandatory" according to the official documentation, but the lone usage example in the official documentation doesn't use the --app flag.
Anyway, it's not really mandatory. It's just implicit, usually. You have to tell Heroku which app you're using, with something like:
$ heroku git:remote -a your_app_name
and then it stops wondering which app to run these commands on.
you did not set git remote to your application, do that first by,
heroku git:remote -a your_app_name
To expand a little further on this (just for the benefit of other new users encountering a similar issue) - below is an example of a command you could enter in macOS Terminal:
heroku logs --tail --app yourexampleservername
If you have deployed yourexampleservername to Heroku, this should then display a log.
I'm trying to run commands for my heroku app in my console, but it keeps telling me "Couldn't find that app." even though when I run heroku apps in my console it tells me I have one app called worldofwarcraft-api
So heroku recognizes my app in the apps list, but I can't run any commands to access it. The line I want to run is
heroku ps:scale web=1 --app worldofwarcraft-api
I'm trying to troubleshoot why my API returns a 503 when I try to make a GET request to it. This is the fix the heroku faq told me to try, but it's just telling me it can't find my app.
I'm wondering if it has something to do with the fact that I deployed my API from github, rather than running the heroku setup in my console. I don't know if that would effect my ability to run heroku commands on the app in my local console.
Apologies if my formatting is off a bit. I'm still getting used to this site.
In my case, someone renamed GitHub repo and I tried to find Heroku app with new GitHub name
It helps me
heroku apps
heroku git:remote -a YOUR_APP
Solved it. Just sharing for future searches.
The issue was fixed by running git init and then heroku git:remote -a worldofwarcraft-api in my command line while inside my repositories folder. This initialized git in the repo and then set the heroku git remote to that repository.
Hopefully, this helps anyone else who had a similar issue.
Just an easy way to solve this issue:
1st: Add the command into your terminal: $ heroku apps
If you already logged into your heroku account from your terminal, all your apps will appear as a list like this:
your-project-name-1
your-project-name-2
your-project-name-3
your-project-name-4
2nd: Then chose which one you are needing to connect with the following command:
$ heroku git:remote -a your-project-name-2
If you've done the connection properly you'll receive the following output:
set git remote heroku to https://git.heroku.com/your-project-name-2.git
For my case, I was renaming my github repository.
You can find it in your repository settings then just rename it, it appears in the first place.
Then you can continue with git init again to re-initiate your existing git repository and then set your heroku remote with your heroku apps new name heroku git:remote -a YOUR_APP_NAME
If the app belongs to a team that you participate in, you have to specify the team option in the commands to see the app:
E.g:
heroku apps -t <team name>
or
heroku ps:scale web=1 --app worldofwarcraft-api -t <team name>
I have two Heroku application in that from one heroku application - I take a dump. Now I want to restore that database to another heroku application. so How Can I do that?
I try this :
heroku pgbackups:restore HEROKU_POSTGRESQL_GREEN_URL "URL" --APP
When I run above command then
HEROKU_POSTGRESQL_COLOR_URL <---restore--- b013.dump
Retrieving... done
Restoring... done
then after when I am checking the database then No records display in the table.
All table records are blank
So What Should I do?
Please Help Me, Thanks In Advance
Heroku has step by step documentation on how to do this:
Heroku Dev Center: Using PG Backups to Upgrade Heroku Postgres Databases
Heroku has recently changed their commands around, here is the newest version of how to do it.
I created a nice little Rake task to backup our Mysql database on ClearDB to a remote Google storage bucket. Works great locally but running it on Heroku I get this error:
sh: mysqldump: not found
Of course, Heroku doesn't have mysqldump, how silly of me, but is there any way to do this?
The command I'm using is something like this:
system "mysqldump -h host.cleardb.com -u user -p'password' --single-transaction database | gz > #{backup_directory}/#{file_name}"
Of course gzip doesn't exist either on Heroku.
I know there are a couple of gems to backup PostgreSQL databases but I haven't seen anything for Mysql.
This is for a Rails 3.2 app.
Any ideas would be appreciated.
I'd say your best option would be a custom build pack that adds the mysql binaries that you need.
https://devcenter.heroku.com/articles/buildpacks
I need to use some PostgreSQL proprietary features such as rules and triggers for table partitioning. As long as I know, these kind of features cannot be dump to schema.rb so I have changed my schema_format configuration parameter to :sql.
Now, when I try to load rake db:structure:load to load the generated structure.sql into the heroku database, it fails saying: sh: psql: not found
How can I do it?
You can use pg:psql to run the script from your development machine against the database:
cd your-rails-project
heroku pg:psql -a your-app-name <db/structure.sql
Just make sure that the branch you have checked out locally is the same as the one you have deployed.