I have unintentionally detached a Hobby-Basic postgres database from my application. Is there any way I can recover the database or the database backup?
I was able to get the database url by using heroku release:info command.
We reached out to heroku support team and they reattached the detached db from their end.
Related
We recently upgraded the plan on Heroku from free. Post this upgrade, our existing database got deleted and Heroku added a new database for the app.
Now we have lost the existing tables and we haven't took a backup for the same. Due to this our app is not connecting.
Is there a way to restore the previous database(PostgreSQL)so that our data will be back and the app will also connect back.
I have unintentionally deleted my Postgres DB on my heroku "Hobby Dev" instance. Does heroku keep a backup that could be used to restore it?
Hobby databases do not have access to the point-in-time recovery feature that is available on the production tier of databases. If you haven't captured any logical backups with heroku pg:backups then there's no way to recover what you've deleted.
Yesterday I uploaded a Rails 5 application with multiple databases to Heroku. I have a hobby-dev postgres add-on. This morning I successfully imported my 7 Postgres databases using pg_dump backups created according to the Heroku documentation.
PGPASSWORD=mypassword pg_dump -Fc --no-acl --no-owner -h localhost -U myuser mydb > mydb.dump
heroku pg:backups:restore 'https://s3.amazonaws.com/me/items/3H0q/mydb.dump' HEROKU_POSTGRESQL_COLOR_URL
Several times I have imported these databases because after a few minutes they disappear. I ran my Heroku app and the first database was successfully accessed but by the time I tried to access the second one I received a 'relation "xxxx" does not exist'. When I went back to my datastore the databases were gone. When I tried to run my app a second time I got a 'relation "xxxx" does not exist' on the first table that I successfully accessed the previous time I ran my app.
I'm not seeing any errors when I look at the data-store for the database. They just disappear. I checked to see if there was a limit to the number of databases I could have with the hobby-dev but did not see any. The row count is under 10,000. Each time I have imported my pg_dump files I get a warning email about the number of rows.
UPDATE 2/17/2017 10:42 AM central: The only thing I have found so far are some posts stating that the Heroku filesystem is ephemeral, and does not persist between dyno restarts. If this is my problem:
How do I know when dynos restart if I don't restart it? I had not restarted my app when my databases disappeared.
How can I permanently store my databases using the Postgres add-on or do I have to store my databases elsewhere? Surely the add-on has a way to permanently store databases.
I assume you use Heroku PostgreSQL offering (instead of trying to set it up on your own). If that's the case the ephemeral nature of dyno file systems shouldn't be your concern.
I recommend that you first create the seven (empty) databases and see if they disappear or not. You can create a single database with
heroku addons:create heroku-postgresql:hobby-dev
After each call run heroku pg:wait to wait until the database has been provisioned. If the databases don't disappear try restoring your backups then.
I've a simple Sinatra application which I've developed using SQLite. The database is a simple two-column table: an ID and a string entry.
I would like to deploy this app to Heroku. What's the least painful way to convert an SQLite database to PostgreSQL, understanding that PostgreSQL is required to deploy to Heroku.
For simple use cases heroku db:push will push your local sqlite database into your Heroku Postgres database.
It's worth considering then switching to using Postgres locally and then use heroku db:pull to bring the database back from Heroku to your new local postgres instance.
I'll caveat to say that whilst heroku db:pull works for SIMPLE databases once you start using more complex Postgres datatypes then you need to use something like heroku pg:transger which is Postgres > Postgres only.
Use the taps gem, as shown in this Railscast.
First you'll want to install Postgres on your local machine so you can make changes and easily deploy to heroku. Second you'll want to migrate from SQLite to Postgres. I just did the migration for my own Rails app following Heroku's instructions and it took less 5 minutes. Seems simple enough.
The instructions to migrate are here (even has instructions on installing Postgres locally). Then you can follow the Heroku getting started guide for the rest.
i have just started working on an application in PHP. I have configured the Postgres add on in my application on Heroku. But i am still not sure how to start working on the DATABASE. what i mean is that there is a thing called DATACLIP on the POSTGRES DB window on Heroku and when i try to create a table there, it gives me some weird errors.
But no matter what query i write there, it always gives me some error. So, i am not sure whether i can create the Tables and insert my data from DATACLIP or not. and If not, from where can i do this?
Dataclips are only useful for read-only queries. Think gist for SQL and data.
To create data on your database, you can:
Use database migrations that run within the heroku platform itself
Connect to your database using the provided credentials from anywhere (you must use SSL). To get credentials, either run heroku pg:credentials <DATABASE_COLOR> --app <YOUR_APP>, or go to your database in http://postgres.heroku.com. You should be able to use pg_admin or any other postgres front end to connect and create tables.
You can connect directly using the heroku toolbelt (and assuming you have a proper psql installation in your dev box) with heroku pg:psql --app <YOUR_APP>. From there just use SQL to create your data (CREATE TABLE, etc)