Import and dump data for Postgresql on Windows 10

If you need to dump the schema and data for your Postgresql database, and may be re-import it to another database or share it with someone, you have the pg_dump and psql utility at help. If you’re using Windows 10 64-bit machine, the psql and pg_dump utility is available at the following path: C:\Program Files\PostgreSQL\11\bin.

To dump the data for your database, use the following command replacing the values as required:

pg_dump.exe -U postgres -d testdb -f D:\BackupData\import_dump.sql

To import the database, use the below command:

psql.exe -U USERNAME -d DATABASENAME -f  BACKUP_FILE_NAME.sql

e.g. replace the parameter values for:

username as postgres

database name as testdb

import sql file (using -f switch) as import_dump.sql or provide the complete path to the file.

psql.exe -U postgres -d testdb -f D:\BackupData\import_dump.sql