Saturday, March 26, 2022

Restore postgres database backup

<postgres database server installation bin directory location>/psql -U <database username> -W -h <database server ip or localhost> -p <database port> -d <database name where backup will be restored> -f <backup file location>

For Example:

/usr/pgsql-13/bin/psql -U test -W -h 127.0.0.1 -p 5432 -d test_db -f test_db.sql


Note : 

Follow below steps and then restore the database backup:

1. Take backup of an existing database. (See how to take backup through command line Postgres database back up)

2. Create a database through PgAdmin or command line or using any postgres database editor

3. Create user for that database and provide rights to database with that user.

4. Now, Restore the backup taken.


For any clarification, write in comment box. I will be happy to help you.