
- Amazon RDS - Home
- Amazon RDS - Overview
- Amazon RDS - Environment
- Amazon RDS - Interfaces
- Amazon RDS - DB Instances
- Amazon RDS - DB Storages
- Amazon RDS - MS SQL features
- Amazon RDS - MS SQL creating DB
- Amazon RDS - MS SQL Connecting to DB
- Amazon RDS - MS SQL DB Export Import
- Amazon RDS - MS SQL DB with SSL
- Amazon RDS - MS SQL DBA Tasks
- Amazon RDS - Oracle Features
- Amazon RDS - Oracle Creating DB
- Amazon RDS - Oracle Connecting to DB
- Amazon RDS - Oracle DB Data Import
- Amazon RDS - Oracle DBA Tasks
- Amazon RDS - MariaDB Features
- Amazon RDS - MariaDB Creating DB
- Amazon RDS - MariaDB Connecting to DB
- Amazon RDS - MariaDB Data Import
- Amazon RDS - PostgreSQL Features
- Amazon RDS - PostgreSQL creating DB
- Amazon RDS - PostgreSQL Connecting to DB
- Amazon RDS - PostgreSQL Data Import
- Amazon RDS - MySQL Features
- Amazon RDS - MySQL Creating DB
- Amazon RDS - MySQL Connecting to DB
- Amazon RDS - MySQL DB Export Import
- Amazon RDS - MySQL DBA Tasks
- Amazon RDS - Multi-AZ Deployments
- Amazon RDS - DB Snapshots
- Amazon RDS - DB Monitoring
- Amazon RDS - Event Notifications
- Amazon RDS - DB Access Control
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Amazon RDS - PostgreSQL Data Import
Amazon RDS PostgreSQL provides easy ways of importing data into the DB and exporting data from the DB. After we are able to successfully connect to the PostgreSQL database we can use CLI tools to run the import and export commands to get the data from other sources in and out of the RDS database.
Below are the steps through which the PostgreSQL data migration happens using the export and import mechanisms.
Importing from an Amazon EC2 Instance
When there is a PostgreSQL server on an Amazon EC2 instance and it needs to be moved to a RDS - PostgreSQL DB instance, we use the below steps to do that.
Export The Data
Create a file using pg_dump that contains the data to be loaded. A dump file containing data and all the meta data of the database is created using the pg_dump utility. The following command in the psql utility cerates the dump file from the database named mydbname.
pg_dump dbname=mydbname -f mydbnamedump.sql
Create Target DB Instance
Next, we create the target DB instance and restore the data into it using the pg_restore command.
createdb [new database name] pg_restore -v -h [endpoint of instance] -U [master username] -d [new database name] [database].dump
Create Target Database
Use psql to create the database on the DB instance and load the data.
psql \ -f mydbnamedump.sql \ --host awsdbpginstance.d34f4mnfggv0.us-west-2.rds.amazonaws.com \ --port 8199 \ --username awsdbuser \ --password awsdbpassword \ --dbname mynewdb