MicroticaMicrotica

Migrate your Strapi app from Heroku to AWS

Move your Strapi app from Heroku to your own AWS account with Microtica in two steps — provision the infrastructure, then migrate your PostgreSQL or MySQL data.

This tutorial walks you through migrating your existing Strapi project from Heroku to AWS using Microtica's ready-made Strapi infrastructure template. It applies to developers running an application on Heroku with a PostgreSQL or MySQL database, and covers:

  1. Setting up Strapi infrastructure on AWS
  2. Migrating the PostgreSQL or MySQL database from Heroku to AWS

If you don't have an existing Strapi project on Heroku, here is a guide on how to deploy a new Strapi application on your AWS account.

One-click deploy

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

Deploy with Microtica

Before you start, make sure you:

1. Set up Strapi infrastructure on AWS

To set up the serverless infrastructure for your existing Strapi application, follow the Deploy an existing Strapi app guide.

When configuring the template, make sure you select postgres or mysql as DatabaseClient.

Once the infrastructure is deployed and ready (about 10 minutes), you can migrate your existing data from Heroku to AWS.

2. 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. This 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. This suppresses all CREATE LOGFILE GROUP and CREATE TABLESPACE statements in the output of mysqldump.

Connect to the Amazon RDS database

To connect your local development environment to AWS, follow the Access the RDS database guide.

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

Move the local database copy to AWS

Load the dump into your Amazon RDS PostgreSQL database 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