CloudThat's Blog
www.cloudthat.com
  • AWS
  • Azure
  • AI/ML
  • Data Analytics
  • DevOps
  • GCP
  • Cybersecurity
  • Test Prep
  • Training
  • Consulting

How-to-Migrate-Heroku-PostgreSQL-Database-to-AWS-RDS-PostgreSQL-using-CLI
Deepak Surendran

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

December 10, 2020 | Comments(3) |

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:

1
yum install git

Now we can Install Heroku cli using below command,

1
curl <a href="https://cli-assets.heroku.com/install.sh">https://cli-assets.heroku.com/install.sh</a> | sh

Please verify the Heroku cli version, once it installed

1
heroku --version

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

1
2
3
yum install -y https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-redhat10-10-2.noarch.rpm
 
yum install postgresql10

6

 

 

 

 

 

 

 

7

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

1
psql --version

8

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

1
heroku login -i

9

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.

10

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

1
heroku pg:psql postgresql-asymmetrical-11483 --app nameless-wave-47716

11

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

1
\dt command,

12

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

1
2
3
psql “host=rdsendpoint port=5432 dbname=db_blog user=blog_user”
 
db_blog=&gt; \dt

13

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

1
2
3
heroku pg:backups:capture  --app nameless-wave-47716
 
heroku pg:backups:download  --app nameless-wave-47716

14

15

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

1
2
3
pg_restore --verbose --clean --no-acl --no-owner -h <strong>rds</strong>-<strong>endpoint</strong>
 
-U dev_user -d dev_db latest.dump

16

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

1
2
3
psql “host=rdsendpoint port=5432 dbname=db_blog user=blog_user”
 
db_blog=&gt; \dt

17

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.


3 Responses to “How To Migrate Heroku PostgreSQL Database To AWS RDS PostgreSQL using CLI”

  1. Ketan December 17, 2020

    Informative! Keep it up

    Reply
  2. Sumit Sumit December 17, 2020

    Good and informative blog! Thanks for this.

    Reply
  3. Ritesh Takrani December 17, 2020

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

    Reply

Leave a Reply

Click here to cancel reply.

Benefit from our new offering 'Azure Mastery Pass' – One pass to attend all our Microsoft Azure courses for 1 year & get trained from best of our Consultants and Microsoft Certified Trainer.



Register Your Interest Now! Please fill out below details & we will revert within 24 hours.

Thank you for your interest.
Oops something went wrong.
Loading...

Follow us for latest articles

Popular Posts

  • Sample Questions for Amazon Web Services Certified Solution Architect Certification (AWS Architect Certification) – Part I
  • Preparing for Azure 70-532 Exam: Developing Microsoft Azure Solutions
  • Preparing for Amazon Web Services Certified Solutions Architect Certification (AWS Architect Certification)
  • Preparing for GCP Associate Cloud Engineer Certification Exam
  • Integrating AWS API Gateway, Lambda and DynamoDB

Recent Posts

  • Sample Questions for Microsoft Power Platform App Maker PL-100 Certification Exam
  • Practice Questions for Passing AZ-500 Microsoft Azure Security Technologies
  • Sample Questions for DP-100 Certification Exam: Designing and Implementing Data Science Solutions on Microsoft Azure
  • Study Guide for Passing AZ-500 Microsoft Certified Azure Security Engineer Associate
  • Study Guide for Microsoft DP-100 Certification Exam: Designing and Implementing Data Science Solution on Azure

Recent Comments

  • Rasika on 8 Easy Steps to prepare for Microsoft Azure Data Fundamentals DP-900 Certification Exam
  • Sakshi on 9 steps to crack the Microsoft Azure AI Fundamentals AI-900 Certification Exam
  • Anusha Shanbhag on Free Sample Questions for PL-900 certification exam Microsoft Power Platform Fundamentals
  • Anusha Shanbhag on A Comprehensive Study Guide To Help You Crack The Microsoft Power Platform Fundamentals PL-900 Certification Exam
  • Anjali on 9 steps to crack the Microsoft Azure AI Fundamentals AI-900 Certification Exam

Archives

Categories

  • AI
  • AI/ML
  • Analysis
  • Analytics
  • API
  • Artificial Intelligence
  • Artificial Intelligence and Machine Learning
  • Automation
  • AWS
  • Azure
  • Azure Machine Learning
  • Big Data
  • Certification BootCamp
  • Cloud Computing
  • Cloud Data Science
  • Comparision
  • Cybersecurity
  • Data Analytics
  • DevOps
  • Docker
  • Google Cloud (GCP)
  • Hadoop
  • Internet of Things (IoT)
  • Interviews
  • Machine Learning
  • Microsoft Azure
  • MongoDB
  • News
  • NoSQL
  • OpenStack
  • Private Cloud
  • Tutorials
  • Uncategorized
  • vCloud Air
  • Videos
  • Windows

Like us for latest articles

© 2021 CloudThat Technologies. All rights reserved.