I am new to Postgres database. I have to get the backup from Production Server (pgAdmin Version is 9.2.4) & restore it on my local machine (I have pgAdmin Version 9.4). I tried to get backup by right clicking on database -> Backup to get the .backup file. Like shown in below image:

But when I try to restore the backup file, I get many errors.
I also want to know whether having different ports at both system can also create issues while restoring backups. As When I tried to restore backup of same system had no problems.
To backup a database you can use pg_dump.exe:
Open Powershell
Go to Postgres bin folder. For example:
cd "C:\Program Files\PostgreSQL\9.6\bin"
Enter the command to dump your database. For example:
./pg_dump.exe -U postgres -d my_database_name -f D:\Backup\<backup-file-name>.sql
Type password for your postgres user
To restore a database you can use psql.exe. (Note, the following is extracted from Alexandr Omelchenko's helpful answer which has been deleted for reasons not clear to me.)
Open Powershell
Go to Postgres bin folder. For example:
cd "C:\ProgramFiles\PostgreSQL\9.6\bin"
Enter the command to restore your database. For example:
./psql.exe -U postgres -d my_database_name -f D:\Backup\<backup-file-name>.sql
Type password for your postgres user
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With