简体   繁体   English

为什么pg_restore返回“选项-d / - dbname和-f / - 文件不能一起使用”?

[英]Why does pg_restore return “options -d/--dbname and -f/--file cannot be used together”?

The following Windows batch script fails on the line with database restore: 以下Windows批处理脚本在数据库还原的行上失败:

@Echo off

set Path=C:\Program Files (x86)
set Backup_Path=C:\Program Files (x86) 

c:  
cd \  
cd C:\Program Files (x86)\PostgreSQL\9.1\bin  

@echo "Wait ..."  
setlocal
set PGPASSWORD=1234
psql.exe -U postgres -c "create database Mydata"  
"C:\Program Files (x86)\PostgreSQL\9.1\bin\pg_restore.exe" -h localhost -U postgres -d Mydata -f "Mydata.backup"

pause 
endlocal

The error is: 错误是:

pg_restore : -d / - dbname and -f / - file can not be used together Try " pg_restore --help " pg_restore:-d / - dbname和-f / - 文件不能一起使用试试“pg_restore --help”

-f is the output filename, not the input file. -f输出文件名,而不是输入文件。

The input file does not have any parameter switch. 输入文件没有任何参数切换。

c:\>pg_restore --help
pg_restore restores a PostgreSQL database from an archive created by pg_dump.

Usage:
  pg_restore [OPTION]... [FILE]

General options:
  -d, --dbname=NAME        connect to database name
  -f, --file=FILENAME      output file name
  -F, --format=c|d|t       backup file format (should be automatic)
  -l, --list               print summarized TOC of the archive
  -v, --verbose            verbose mode
  -V, --version            output version information, then exit
  -?, --help               show this help, then exit

So you need to use: 所以你需要使用:

pg_restore.exe -h localhost -U postgres -d Mydata "Mydata.backup"

More details in the manual: http://www.postgresql.org/docs/current/static/app-pgrestore.html 手册中的更多细节: http//www.postgresql.org/docs/current/static/app-pgrestore.html

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

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