Amazon RDS - PostgreSQL Data Import

Amazon RDS – PostgreSQL Data Import

Amazon RDS PostgreSQL supplies straightforward methods of importing knowledge into the DB and exporting knowledge from the DB. After we’re in a position to efficiently connect with the PostgreSQL database we are able to use CLI instruments to run the import and export instructions to get the info from different sources out and in of the RDS database.

Beneath are the steps via which the PostgreSQL knowledge migration occurs utilizing the export and import mechanisms.

Importing from an Amazon EC2 Occasion

When there’s a PostgreSQL server on an Amazon EC2 occasion and it must be moved to a RDS – PostgreSQL DB occasion, we use the under steps to do this.

Export The Information

Create a file utilizing pg_dump that comprises the info to be loaded. A dump file containing knowledge and all of the meta knowledge of the database is created utilizing the pg_dump utility. The next command within the psql utility cerates the dump file from the database named mydbname.

pg_dump dbname=mydbname -f mydbnamedump.sql 

Create Goal DB Occasion

Subsequent, we create the goal DB occasion and restore the info into it utilizing 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 Goal Database

Use psql to create the database on the DB occasion and cargo the info.

 

 
psql 
   -f mydbnamedump.sql 
   --host awsdbpginstance.d34f4mnfggv0.us-west-2.rds.amazonaws.com 
   --port 8199 
   --username awsdbuser 
   --password awsdbpassword 
   --dbname mynewdb