6

The following Windows batch script fails on the line with database restore:

@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 "

2
  • Remove the -f switch. It is not a switch for specifying input file as you might think. Commented Jan 10, 2015 at 23:13
  • Why do you use such an old version for a new install? Commented Jan 10, 2015 at 23:16

1 Answer 1

17

-f is the output filename, not the input file.

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

Sign up to request clarification or add additional context in comments.

1 Comment

Now my setup installs my software ,my database and makes a restore :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.