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.
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 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.
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 created an app on heroku with two postgresql databases, and set up an automatic backup with the command:
heroku addons:add pgbackups:auto-month
But the backups are not being created. Am I missing something else?
Edit:
I was suggested to create promote a default database, but this would make the backup work only for one database. How do I enable the backups for both databases?
With the pgbackups auto plans, backups are taken of the database pointed at by DATABASE_URL in your config. Is any of those databases DATABASE_URL? If not, promote one of them, your primary, with heroku pg:promote HEROKU_POSTGRESQL_<color> -a <app>, and backups should be taken nightly.
In addition to these backups, physical snapshots of all databases are taken nightly, which in addition to WAL archival are the best way to do disaster recovery, especially as your database grows in size. Think of pgbackups dumps/restores as a way of exporting and importing data, not a DR tool. See https://devcenter.heroku.com/articles/heroku-postgres-data-safety-and-continuous-protection
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)