postgresql database backup and restore under the backup windows PGSQL

Under windows postgresql database backup and restore

1, by cmd into the bin directory database

cd C:\Program Files\PostgreSQL\9.6\bin

2, the implementation pg_dump backup command, localhost or IP

pg_dump -h host -p port -U username  -d dbname> C:\dbname.bak

After the implementation, will remind password is to enter a password

示例:pg_dump -h localhost -p 5432 -U postgres -d ship> C:\ship.bak

3, execute psql to restore order, before that, the need to build a database of the same name blank
psql -h localhost -p 5432 -U postgres -d ship <C: \ ship.bak

psql -h localhost -p 5432 -U postgres -d ship -f "C:\ship.bak"

 

Guess you like

Origin www.cnblogs.com/hd13/p/12559006.html