How to restore Postgresql dump to Amazon RDS database?
2023-01-25
With command-line
Here are the steps to restore a PostgreSQL dump to an Amazon RDS database:
Create an RDS instance with PostgreSQL compatibility, if you don’t have one.
Connect to your RDS instance using the psql command-line client or a PostgreSQL-compatible tool of your choice.
- Create the database on RDS by running the following command:
1 | CREATE DATABASE [DATABASE_NAME]; |
- Use the following command to import the PostgreSQL dump file to the newly created database:
1 | pg_restore -h [RDS_ENDPOINT] -U [USERNAME] -d [DATABASE_NAME] -Fc [SQL_DUMP_FILE].dump |
Replace [RDS_ENDPOINT], [USERNAME], [DATABASE_NAME], and [SQL_DUMP_FILE] with the appropriate values for your RDS instance and the PostgreSQL dump file you want to import.
When prompted, enter the password for the user specified in the command.
Once the import process is completed, you should be able to see the imported data in your RDS PostgreSQL database.
Note that the format of the dump file should be in pg_dump format.