简体   繁体   中英

How to restore .bak file using pg_restore command through cmd in PostgreSQL?

I have a test.bak file created with pg_dump command which has a hypertable and i have created a new database Performance_Test in postgreSQL.

The database was dumped using the command:

pg_dump -h localhost -U postgres -p 5432 -Fc -f "D:\Database Backup\temp.bak" Performace_Test

I want to restore that test.bak file in Performance_Test.

How can i do that?

You can restore doing the below(with caveats noted further on):

pg_restore -h localhost -d Performace_Test -U postgres -p 5432 "D:\Database Backup\temp.bak"

The caveats are:

  1. If Performace_Test was created as mixed case by quoting you will need to quote the name above eg "Performace_Test"

  2. If Performace_Test is not empty then you will get a bunch of errors.

  3. Also assumes that Performace_Test is on the same cluster as you specified in the pg_dump command.

     psql Performance_Test < test.bak

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM