MicroticaMicrotica

Migrate from Heroku to AWS

Move your Heroku app to your own AWS account with Microtica's ready-made infrastructure and templates, including your PostgreSQL or MySQL database.

This is a step-by-step tutorial for migrating a running project from Heroku to AWS, using Microtica's ready-made infrastructure and application templates. It applies if you have an application on Heroku backed by a PostgreSQL or MySQL database, and it covers:

  1. Setting up infrastructure on AWS
  2. Importing your existing application
  3. Migrating your PostgreSQL or MySQL database from Heroku to AWS

One-click deploy

Click the Deploy with Microtica button below and follow the template steps to migrate your existing Heroku application to your AWS account.

Deploy with Microtica

If you want to deploy a new application on AWS instead, see Deploy your first application.

1. Create an EKS cluster on AWS

You can provision a complete Kubernetes infrastructure through Microtica, or connect an existing Kubernetes cluster running on almost any cloud provider or on-premise.

Microtica K8s is fully integrated with Microtica pipelines, so you can define the automation to build, test, and deploy services on Kubernetes in one place.

To create a Kubernetes infrastructure on your AWS account, follow the complete guide below.

Amazon EKS

A step-by-step guide to creating a Kubernetes cluster on your AWS account.

2. Import your existing app

With our templates, you can import any application you already have on your Git account. We support all the popular Git providers: GitHub, GitLab, Bitbucket, and CodeCommit. Import your repository, select a cluster, and deploy your app. Follow the tutorial below.

Import an existing app

A step-by-step guide to importing your existing application and deploying it on AWS.

3. Migrate the database from Heroku to AWS

Download all data from the Heroku database locally

To export the data from your Heroku Postgres database, create a new backup and download it with the following commands:

PostgreSQL
heroku pg:backups:capture --app example-app
heroku pg:backups:download --app example-app

To export the data from your Heroku MySQL database, dump the Heroku database to your local development environment using the mysqldump tool.

MySQL
mysqldump --set-gtid-purged=OFF --single-transaction -hHOST_HERE -uUSER_HERE -P PORT_HERE -p DB_NAME_HERE > heroku_db

# --set-gtid-purged=OFF - required property for RDS because you don’t have full permission in RDS.
# --single-transaction – Use to ensure that all of the data loaded from the local database is consistent with a single point in time. If there are other processes changing the data while mysqldump is reading it, using this option helps maintain data integrity.
# -h - hostname of the DB. No space between -h and the value.
# -u – Use to specify a user name. No space between -u and the value.
# -P - mysql port
# -p - once the command is run you’ll be asked for the DB password
# DB_NAME_HERE - the name of the database you want to download locally

If you get the error message "Unknown table 'COLUMN_STATISTICS' in information_schema", add the command --column-statistics=0. The command adds ANALYZE TABLE statements to the output to generate histogram statistics for dumped tables when the dump file is reloaded.

If you get the error message "Access denied; you need (at least one of) the PROCESS privilege(s) for this operation", add the command --no-tablespaces. The command suppresses all CREATE LOGFILE GROUP and CREATE TABLESPACE statements in the output of mysqldump.

Connect to the Amazon RDS database

To establish a connection between your local development environment and AWS, follow the Access the RDS database guide.

Once the connection is established, you can move the local copy of the data to AWS.

Move the local database copy to AWS

Load the dump into your Amazon RDS PostgreSQL using the pg_restore tool.

PostgreSQL
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U dbuser -d strapi latest.dump

Load the dump into your Amazon RDS MySQL database using the mysql tool.

MySQL
mysql -udbuser -h localhost -P 3306 -p strapi < heroku_db

Next steps

On this page