Thursday, June 29, 2023
Share this article:
We were trying out the new hosting tool, Render, for Receipt-AI.com, and we ended up regretting it. Even though we were paying for their starter plan, we experienced numerous disconnection issues. After spending two days dealing with these problems, I decided to switch back to Heroku for my Rails app. Let me share with you the steps I took to make the transition.
The process of downloading and uploading a Postgres database is called 'pgdump' and 'pgrestore'. Since we need to migrate from Render to Heroku, the first step is to connect to Render and download the database.
Make sure your VPN is turned off and add the correct IP address. This will enable you to connect to your database on Render from your local machine.
-Fc
for correct compression format.Run pg_dump -Fc -d postgres://{YOUR_POSTGRESS_URL}
on your local machine to download the database.
-Fc
is the format for Heroku. If a backup is created with the incorrect format, pg_restore
will not be able to restore the dump file. You may see an error like this: pg_restore: [archiver] did not find magic string in file header.
To run pg_dump
from your local machine, install 'pgdump' using homebrew. Remember the version of `pgdumphas to be the same as Render's. Otherwise you will see this error
pg_dump: error: aborting because of server version mismatch. `
Some additional details and instructions are available here. https://devcenter.heroku.com/articles/heroku-postgres-import-export#create-dump-file
Heroku doesn't allow database uploads from a local machine, so you need to store the database in a publicly accessible bucket in the cloud. Both Google Cloud and AWS are suitable options. Remember to delete it after restoring the database.
Assuming you have already created an account on Heroku and completed all the necessary preparations to run your app, you can now proceed by running this command to restore your database.heroku pg:backups:restore '<SIGNED URL>' DATABASE_URL --app example-app
If your app is already running on Basic or Professional dynos, enable Automated Certificate Management
with the following command:
heroku certs:auto:enable
heroku data for redis
It's a way easier setup. Starting plan costs $3/month.
Source: https://devcenter.heroku.com/articles/heroku-redis
Redis Enterprise Cloud
to save $3/month:Set the REDIS_PROVIDER
env var to the name of the env var containing the Redis server URL. (Example with RedisCloud: set REDISPROVIDER=REDISCLOUDURL and Sidekiq will use the value of the REDISCLOUD_URL env var when connecting to Redis.)
Run this command: heroku config:set REDIS_PROVIDER=REDISCLOUD_URL
Source: https://github.com/sidekiq/sidekiq/wiki/Using-Redis
You may see this error if you are running Sidekiq 7+
redis-client requires Redis 6+ with HELLO command available
You have to downgrade Sidekiq to 6.5.8 version for it to work.
worker: bundle exec sidekiq -C config/sidekiq.yml
release: bin/rails db:migrate
You are almost there:
Copy all your environment variables from Render to Heroku, ensure everything is up and running, and confirm that your Sidekiq jobs are executing. Once you have verified these aspects, you can safely suspend the usage of Render. You may also delete all the YAML files that were generated by Render from your repository.
🎉 Congratulations! You have successfully migrated from Render to Heroku. Woo wee! I hope this guide proves helpful to you, and feel free to share it with anyone who may encounter similar challenges. Also, don't forget to check out https://receipt-ai.com —it's up and running.
ruby on rails
receipt scanner
Heroku
Render
receipt ai
Save 97% of your time with efficient receipt processing
Works with Xero and QuickBooks
Perfect for businesses, big and small
No extra app downloads. Works with tools you already have (Email and SMS)