Autobus add-on is being removed from Heroku - heroku

I just received an email from Autobus saying that due to "Salesforce's complete and long-term failure to fulfill its obligations to us we have to stop our service starting December 1, 2022.".
That is very unfortunate as we don't really have an alternative add-on (Remora Offsite Backup starts at $75/month).
Does anyone know how to automatically backup Postgres database from Heroku automatically without Autobus help?

For now we have to setup scheduled backups using the Heroku CLI...
heroku pg:backups:schedule DATABASE_URL --at '20:00 America/Sao_Paulo'
More details at https://devcenter.heroku.com/articles/heroku-postgres-backups

Related

Keep data after Heroku dyno restart

I have a twitter bot hosted at Heroku, and once a day the server reboots. I have a text file that is constantly being modified, and when the server is restarted the changes in that file are lost. Does anyone know how to keep that file updated when the server is restarted?
Yes,you have to pay heroku for dynos : https://devcenter.heroku.com/articles/dynos
Or you can always choose to deploy it somewhere else
Heroku file system is ephemeral and gets wiped out at every restart.
A solution (if you want to keep using Heroku) is to use an external service to persist your data:
Amazon S3, see Heroku article
Github, an easy and free option if you need to perform simple get/put, see an example
A database (Atlas MongoDB has a free tier which can be used in cases like yours)

Is it possible to force a database credential update on Heroku?

Heroku sent an email regarding scheduled maintenance for a hobby-dev hosted Postgres database I have. I received confirmation that the scheduled maintenance had been successfully completed and that my updated database credentials would reflect this.
After updating the environment variables in my app to reflect this change, I can no longer connect to the database. Scheduled maintenance changes have completed before with no issues, this is the first time I'm receiving this error.
Authentication failed against database server at `ec2-176-34-114-78.eu-west-1.compute.amazonaws.com`, the provided database credentials for `mydb` are not valid.
However, when I log into Heroku to view the database instance, the health checks are showing that it's available.
I've now tried using the new and old database credentials, but both are unable to connect to the DB. It also appears that I am unable to directly contact support on the hobby dev plan.
Do I have any other options to try troubleshoot this? Is it possible to force a new database credential update on Heroku?
Yes, you can use heroku pg:credentials:rotate to generate new credentials. But you shouldn't have to do this.
After updating the environment variables in my app to reflect this change
As the email told you, your credentials would automatically have been updated. There was nothing for you to do. As long as you are connecting via the DATABASE_URL environment variable, which is always recommended with Heroku Postgres¹, you should be good to go.
heroku pg:credentials:rotate behaves the same way, so running that command without understanding this isn't likely to help much.
¹Heroku may update these credentials at any time. Connecting via that environment variable is the best way to ensure you can always connect.

Cloudant add on Heroku not working

I am trying to install cloudant on my vulcan based app.
However when I try to add the free version of cloudant through the heroku addons I get the following error:
Could not communicate with vendor, please try again later
Want to confirm if this is a temporary vendor issue or is it something with my app?
I contacted Heroku support and was told Heroku is in the process of removing the add-on. I don't know any further details, but it looks like in order to have Cloudant work on Heroku you'll need to set the account up yourself.
This sounds like an error in the brokering between Heroku and Cloudant. If you can file a ticket with support#cloudant.com (including account information and time of the failure) we can track it down on our side and see if there's action we can take. Alternatively, you can always signup directly at cloudant.com as a short-term work around.

Heroku: rogue transfer in progress

I started a migration on Heroku last night that gave me no feedback for hours, and which I eventually stopped because it wasn't clear if the system was even doing anything.
Ever since, it's been a nightmare. I cannot access the relevant database tables in heroku console, I can't migrate, rollback, or use pgbackups.
Helpfully, pgbackups gave me a one line explanation just now:
a transfer is currently in progress
This I assume is the migration I tried to execute hours ago. How can I stop whatever Heroku is doing so I can do a quick restore and get back up and running?
You can remove the problem backup stuck in the "a transfer is currently in progress" by finding the name of the backup and then destroying it. E.g.
heroku pgbackups
My problem backup was listed like this:
b210 | 2013/01/02 12:29.33 | unknown | DATABASE_URL
So to destroy it I just did:
heroku pgbackups:destroy b210
It removed the problem backup for me so I could get on with using pgbackups again properly.
I just had this problem too. Found an easier way of fixing it - briefly remove the pgbackups addon.
heroku addons:remove pgbackups
heroku addons:add pgbackups
WARNING as mentioned in the comments below, this will destroy all extant backups!
I accidentally did a transfer from my COLOR_URL database to my DATABASE_URL which was the same database. heroku pgackups:transfer let this happen which caused the main database to get stuck in
a transfer is currently in progress
I fixed it by looking at the process list pg:ps and killing all connections pg:killall
After doing this and looking at pg:ps the process list was empty and I was free to use the main database again with pgbackups.
NOTE this could be a destructive operation so make sure you have a snapshot before you do this.
The real solution is to contact Heroku support and have them kill the rogue process for you. They say they are re-architecting pgbackups to give users more control.
It never became clear what happened - after a day or so I was able to interact with heroku console, but I was never able to run another migration. This is what I did:
Renamed my app to something else.
Created a new app in its place, checking the stack was the same, and copying over all add-ons and domains.
I restored the database from pgbackups (highly recommended if you're not using this add-on).
This fixed the problem. Note: Be careful to check that your pgbackup doesn't cause unacceptable data loss.

Hot deploy on Heroku with no downtime

A bad side of pushing to Heroku is that I must push the code (and the server restarts automatically) before running my db migrations.
This can obviously cause some 500 errors on users navigating the website having the new code without the new tables/attributes: the solution proposed by Heroku is to use the maintenance mode, but I want a way with no downside letting my webapp running everytime!
Is there a way? For example with Capistrano:
I prepare the code to deploy in a new dir
I run (backward) migrations and the old code continue to work perfectly
I swith mongrel instance to the new dir and restart the server
...and I have no downtime!
You could setup a second Heroku app which points to the same DB as your primary production app and use the secondary app to run your DB migrations without interrupting production (assuming the migrations don't break the previous version of your app).
Let's call the Heroku apps PRODUCTION and STAGING.
Your deploy sequence would become something like:
Deploy new code to STAGING
git push heroku staging
Run database migrations on STAGING (to update PROD db)
heroku run -a staging-app rake db:migrate
Deploy new code to PRODUCTION
git push heroku production
The staging app won't cost you anything since you won't need to exceed Heroku's free tier and it would be pretty trivial to setup a rake deploy script to do this for you automatically.
Good luck!
If you're able to live with two versions of the same app live at the same time, Heroku now has a preboot feature.
https://devcenter.heroku.com/articles/preboot
The only method to improve the process somewhat is what this guy suggests. This is still not a hot deploy scenario though:
http://casperfabricius.com/site/2009/09/20/manage-and-rollback-heroku-deployments-capistrano-style/
One thing I would suggest is pushing only your migrations up to Heroku first and running them before you push your codebase. This would entail committing the migrations as standalone commits and manually pushing them each time (which is not ideal). I'm very surprised there is not a better solution to this issue with all of the large apps hosted on Heroku now.
You actually will have some downtime when Heroku restarts your app. They have a new feature called Preboot that starts up new dynos before taking out the old ones: https://devcenter.heroku.com/articles/labs-preboot/
As for database migrations, that article links to this one on how to deal with that issue: http://pedro.herokuapp.com/past/2011/7/13/rails_migrations_with_no_downtime/
I first commit the migrations, run them, then push the rest of the code. Add a single file like so:
git commit -m 'added migration' -- db/migrate/2012-your-migration.rb
Heroku can't deploy by capistrano. You are block by tool released by heroku.
The no downtime system is impossible in all cases. How change your schema with big change without stop your server. If you don't stop it, you can avoid some change and your database can be inconsistent. SO the using of maintenance page is a normal solution.
If you want a little solution to avoid problem is a balancing in two server. One with only read database during your migration. You can switch to this instance during your migration avoiding the maintenance page. After your migration you come back to your master.
Right now I don't see any possibility to do this without downtime. I hate it too.
This console command does it in the smallest amount of time I can think of
git push heroku master &&
heroku maintenance:on &&
sleep 5 &&
heroku run rails db:migrate &&
sleep 3 &&
heroku ps:restart &&
heroku maintenance:off
git push heroku master to push the master branch to heroku
heroku maintenance:on to put on maintenance so no 500s
sleep 5 to let the dynos start up the new code (without it, the migration might fail)
heroku run rails db:migrate to do the actual migration
heroku ps:restart out of experience the restart makes sure the new dynos have the latest schema
heroku maintenance:off turns of the maintenance
You might have to add -a <app name> behind all heroku commands if you have multiple apps.
Just one command will run these in series in terminal on Mac OSX.

Resources