为什么 pg_restore return "options -d/--dbname and -f/--file cannot be used together"?
Why does pg_restore return "options -d/--dbname and -f/--file cannot be used together"?
以下 Windows 批处理脚本在恢复数据库时失败:
@Echo off
set Path=C:\Program Files (x86)
set Backup_Path=C:\Program Files (x86)
c:
cd \
cd C:\Program Files (x86)\PostgreSQL.1\bin
@echo "Wait ..."
setlocal
set PGPASSWORD=1234
psql.exe -U postgres -c "create database Mydata"
"C:\Program Files (x86)\PostgreSQL.1\bin\pg_restore.exe" -h localhost -U postgres -d Mydata -f "Mydata.backup"
pause
endlocal
错误是:
pg_restore : -d / - dbname and -f / - file can not be used together
Try " pg_restore --help "
-f
是 output 文件名,而不是输入文件。
输入文件没有任何参数开关。
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
所以你需要使用:
pg_restore.exe -h localhost -U postgres -d Mydata "Mydata.backup"
手册中有更多详细信息:http://www.postgresql.org/docs/current/static/app-pgrestore.html
以下 Windows 批处理脚本在恢复数据库时失败:
@Echo off
set Path=C:\Program Files (x86)
set Backup_Path=C:\Program Files (x86)
c:
cd \
cd C:\Program Files (x86)\PostgreSQL.1\bin
@echo "Wait ..."
setlocal
set PGPASSWORD=1234
psql.exe -U postgres -c "create database Mydata"
"C:\Program Files (x86)\PostgreSQL.1\bin\pg_restore.exe" -h localhost -U postgres -d Mydata -f "Mydata.backup"
pause
endlocal
错误是:
pg_restore : -d / - dbname and -f / - file can not be used together Try " pg_restore --help "
-f
是 output 文件名,而不是输入文件。
输入文件没有任何参数开关。
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
所以你需要使用:
pg_restore.exe -h localhost -U postgres -d Mydata "Mydata.backup"
手册中有更多详细信息:http://www.postgresql.org/docs/current/static/app-pgrestore.html