简体   繁体   English

如何通过PostgreSQL中的cmd使用pg_restore命令恢复.bak文件?

[英]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.我有一个用 pg_dump 命令创建的 test.bak 文件,它有一个超表,我在 postgreSQL 中创建了一个新的数据库 Performance_Test。

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.我想在 Performance_Test 中恢复那个 test.bak 文件。

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"如果通过引用将 Performace_Test 创建为大小写混合,则需要引用上面的名称,例如“Performace_Test”

  2. If Performace_Test is not empty then you will get a bunch of errors.如果 Performace_Test 不为空,那么您将收到一堆错误。

  3. Also assumes that Performace_Test is on the same cluster as you specified in the pg_dump command.还假定 Performace_Test 与您在pg_dump命令中指定的集群相同。

     psql Performance_Test < test.bak

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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