How to restore postgreSQL from dump file to AWS?

Question:

I have PostgreSQL dump file in my local environment, and I want
to restore it on AWS server where Django app was deployed.

I think I should upload the dump file to AWS server but I don’t know
where it should be uploaded to and how to restore it.

Asked By: daily_roppo

||

Answers:

Use pgrestore to restore your database.

Link : https://www.postgresql.org/docs/9.2/app-pgrestore.html

Inorder to get a dump of your database use pgdump.

Link : https://www.postgresql.org/docs/9.6/app-pgdump.html

Answered By: High-Octane

First, copy your file from your local environment to AWS using scp command

e.g

scp -i /directory/to/abc.pem mydump.sql [email protected]:/tmp/

where abc.pem is your private aws key. mydump.sql is your dump file and /tmp/ is the path where the dump file will be copied

Once the file is copied to your AWS /tmp folder or whatever location you use, Next you need to restore it to your database e.g using

./pg_restore -U postgres -p 5432 -d yourdatabase < mydump.sql
Answered By: Amjad Shahzad