How to take database dump and restore in PostgreSQL

Dump method is to generate a file with SQL commands that, when fed back to the server, will recreate the database in the same state as it was at the time of the dump. PostgreSQL provides the utility program pg_dump for this purpose.

for this tutorial we already have two dbs created with with name "test_db" and "test_user_db_restore". "test_db" is having some tables in it which would be restored in "test_user_db_restore".
if you don't have dbs created than follow the link How to create database and tables in create dbs and tables.

  • Switch to postgres user
  • Execute the dump command as shown below and check created dump
  • Restoring the Dump
  • Categories: PostgreSQL