This tutorial describes how to migrate your web application running on Heroku to Qovery. In the article, you learn how to migrate a Node.js application connected to Heroku Postgres as a backing service on the Heroku platform. It covers all required steps you need to take to deploy your application on Qovery and transfer your data from Heroku Postgres to the database managed by Qovery.
The application is a simple Node.js Todo web app that uses PostgreSQL as a persistence layer.
- You are familiar with Heroku basics, have a Heroku account and access to Heroku CLI
- You have a Qovery account
- You have a Github or Gitlab account
Deploying the sample application to Heroku
Log in to Heroku using the CLI:heroku login --interactive
Clone the application repository:git clone https://github.com/qovery/migrate-webapp-from-heroku-to-qovery.git
Move to the directory of the cloned repository:cd migrate-webapp-from-heroku-to-qovery
The repository is made of a few simple components:
index.js- Node.js script for setting up the web application.
package.json- File determining app's dependencies.
Procfile- File required to run the app on Heroku. It determines the command executed on the application startup.
views- Directory with the HTML served by the app.
Create a Heroku app:heroku create
Add Heroku PostgreSQL to your application:heroku addons:create heroku-postgresql:hobby-dev
Deploy the application:git push heroku master
Check your application URL:heroku info
In the browser, navigate to your application's URL - you'll see a simple view with a Todo app:
Create a few Todo tasks in the UI to make sure you have sample data in the database.
Migrating the application from Heroku to Qovery
Create a new project
Create a new environment
Create a new application
To follow the guide, [you can fork and use our repository][https://github.com/qovery/migrate-webapp-from-heroku-to-qovery.git]
Use the forked repository (and branch master) while creating the application in the repository field:
Create and deploy a new database
To learn how to do it, you can follow this guide
Migrate PostgreSQL data
There are multiple paths you could take to migrate your data from Heroku Postgres to Qovery. For production usage for the shortest downtime you would probably want to configure Qovery PostgreSQL as a replica to the database on Heroku, and making it the primary instance after migration. Heroku does not support this in its free tier, so for the purpose of the example, we take a simpler path and use different tools to migrate the data.
First, dump the data from your Heroku Postgres:heroku pg:backups:download -a YOUR_APPLICATION_NAMEheroku pg:backups:capture -a YOUR_APPLICATION_NAME
It results in creating a new
latest.dumpfile, which you use to transfer data to Qovery.
To migrate the data to Qovery, run (replace all the values with secrets listed in your application
Secretstab):pg_restore -v -h $QOVERY_DATABASE_MY_POSTGRESQL_HOST -U $QOVERY_DATABASE_MY_POSTGRESQL_USER -d postgres latest.dump --no-owner
Deploy the app on Qovery
All you have to do now is to navigate to your application and click Deploy button
That's it. Watch the status and wait till the app is deployed.
After it's done, click on Action and Open button to navigate to your app. It should be up and running with all the data from Heroku migrated to Qovery!