AWS, Cloud Computing

3 Mins Read

How To Migrate Heroku PostgreSQL Database To AWS RDS PostgreSQL using CLI

Postgre SQL


Postgresql is one of the most widely used Open-source Databases in the modern Era. Millions of developers and companies believe that PostgreSQL as their transactional data store to drive application health and decision-making. And developers with knowledge of Oracle or MySQL databases can use their SQL querying experience to quickly leverage PostgreSQL’s capabilities as a quick, functional, and powerful data resource.

Today I am going to explain about Migration of Heroku PostgreSQL Database to AWS RDS PostgreSQL. I think most people are aware of the Heroku Cloud. Please click here to know more about Heroku Cloud.

We have several methods for performing this Migration. Today I am explaining Migration using the pg_dump and pg_restore method. I am using centos 7 Instance as a middle Instance for migration. You can use Windows, Mac or any System depends upon your easiness.

First, we need to install Heroku CLI on our Machine. Before that, we need to install git as a prerequisite:

Now we can Install Heroku cli using below command,

Please verify the Heroku cli version, once it installed

We have installed the Heroku cli successfully. Now we can install PostgreSQL client,










PostgreSQL client is installed now, we can check the version,


Next, we need to login into our Heroku account using the below command


Then please log in to our Heroku Account using a browser and select our PostgreSQL database and click on settings from the menu and click on view credentials.


Login to our Heroku PostgreSQL using Heroku CLI (PostgreSQL connection string)


Now we connected to our database. We can list the tables using:


Now we can see some of the tables are residing in the given database. Please login to our AWS RDS and verify the table.


Next, we are going to create and download a backup of our Postgresql database using the below commands,



We export our dump file to our system, now we need to restore it into our AWS RDS using the below command,


Login to the RDS and verify the table, once the restoration completes,


Today we have learned about the migration of the Heroku PostgreSQL database to AWS RDS using cli.

Please share your valuable feedback in the comment section.

Voiced by Amazon Polly

WRITTEN BY Deepak Surendran



  1. Ritesh Takrani

    Dec 17, 2020


    Thank you for the wonderful explanation.
    Keep up the good work.

  2. Sumit

    Dec 17, 2020


    Good and informative blog! Thanks for this.

  3. Ketan

    Dec 17, 2020


    Informative! Keep it up

  4. Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!