$ heroku pg:pull DATABASE_URL mylocaldb2 --app afternoon-sunday-4103
heroku-cli: Pulling postgresql-globular-1902 ---> mylocaldb2
it then stalls out at
pg_dump: dumping contents of table photos
I ran it three times now, including over night. This is not a large database.
$ heroku pg:info
Tables: 32
Rows: 1775
Data Size: 9.9 MB
$ heroku pg:psql
psql (9.4.10, server 9.4.9)
How do I troubleshoot? I am trying to pull my production database to my local database. My local databases are all empty.
I could not get this to work and just used capture/download instead.
https://devcenter.heroku.com/articles/heroku-postgres-import-export
Related
I'm trying to push a local PostgreSQL database to one I've created on a Heroku app. To set up the Heroku database, I ran heroku addons:create heroku-postgresql:hobby-dev -a jasons-react-jobly-app, where jasons-react-jobly-app is the name of my Heroku app.
Then I ran heroku pg:push jobly DATABASE_URL -a jasons-react-jobly-app, where jobly is the name of my local database.
This throws the below error:
heroku-cli: Pushing jobly ---> postgresql-animate-30221
case
------------------------------------
0.9992547478473790.999254747847379
(1 row)
! Cannot read property 'includes' of undefined
The error looks like an error that JavaScript throws when it tries to read properties of an undefined object or something, but I'm not sure where that would be happening in this database push. The app runs completely fine on my local machine with no errors. There is no case column in any of my database tables, so I'm not sure where that number is coming from either.
Also, if I check my Heroku config variables with heroku config, I see:
DATABASE_URL: postgres://iqawqkjfiybndd:c3e921131c239ccd6c880ad4b601deeaa4558339a90ebedc562a5575c9099f42#ec2-54-156-85-145.compute-1.amazonaws.com:5432/dul2u6r13aq5i
So I know the database exists.
Any help with solving this error?
You need to fetch the name of the DB that you see attached to the heroku app on heroku dashboard.
At this url https://dashboard.heroku.com/apps/{put-your-app-name-here}/resources
To get all app names in heroku cli do heroku apps and you will know which app's DB name you want from its dashboard.
Once you have the name of the DB (it will look like this "postgresql-pointy-81624")
use that name in the command to push local db to that db on heroku .
Here are steps to make sure everything works correctly
1- Check the connectivity to the heroku db first by doing
heroku pg:psql postgresql-[somedb name as found above] --app {your-app-name}
2- If it says to reset the DB and you can afford to reset then reset it using
heroku pg:reset -a {your-app-name}
3- Lastly do the migration of DB using this command
heroku pg:push jobly postgresql-[db name found above] -a {your-app-name}
if everything works as expected you will see this message
heroku-cli: Pushing complete.
I have a demo heroku app running rails 4 on the free heroku tier with pgsql.
Somehow, probably due to a bug, a table appears to have been dropped, but I can't find anything in the logs that shows what happened.
Is there a way to restore JUST the missing table via the heroku command line, without blowing away the other data in the dev site? Or is it only possible to push the entire local database to heroku at one time?
If you're running PostgreSQL locally too, you can:
pg_dump -h localhost ... -t thetablename | psql $(heroku pg:credentials DATABASE)
to selectively dump that table locally and restore it to the remote DB.
We're having trouble with the heroku fork command so are manually trying to create a staging environment. I tried creating a new database off of a backup from our prod db but the created db has no rows and is only 6.4MB. The actual backup is 15.7 GB.
I did this via the web console clicking "restore".
Whats the right way to do this?
From the command line, you want to do:
heroku pgbackups:restore DATABASE -a example-staging `heroku pgbackups:url -a example`
We use this command every few days, whenever we want the staging database to be replaced with the production database. This comes from: https://devcenter.heroku.com/articles/migrate-heroku-postgres-with-pgbackups#transfer-to-target-database
Using the heroku toolbelt a person can run the following command and receive some stats about the postgres database connected to the application:
pg:info
if you are not within an application directory you will recieve the following error:
"No app specified."
but if you specify an app, then you will only be able to pull stats on the databases that where created an connected to an application. But, Heroku Postgres lets you create databases that are not connected to a specific application.
How do you use pg:info with a databases that is outside a heroku application?
There is some information in the heroku docs about how to use the pg:info command, but they don't mention how to use it with a standalone database.
You cannot use pg:info with Standalone Heroku Postgres databases at this time.
I want to migrate my application from Heroku to my own ubuntu server. What is the correct syntax to do this using taps/heroku db:pull?
If you are moving data between a local and cloud database both of which are Postgres you should follow the instructions on Heroku's Devcenter:
https://devcenter.heroku.com/articles/migrating-data-between-plans
You would simply do heroku db:pull to pull the database from Heroku to your local db which you would then backup and restore to your own server. If it's a large database you might want to look into Heroku pgbackups as an alternative as it will provide you with a downloadable backup.
Note: If you want to migrate between databases, ie postgres => mysql then you would have to use the db:pull approach.