0

This is how i used to create all the time backups of my databases with PostgreSQL 9.2.x:

pg_dump -Fc -Z 6 -U postgres mydatabase > 2013-xx-xx_xxxxx.db

However on a machine where PostgreSQL with version 9.2.3 is running I get all the time the error "too many command line arguments" starting with "-Z". If I remove -Z he is complaining about "-U"? What is wrong?


Okay there is definitely sth. wrong. I removed argument for argument until i just started pg_dump. Then i added argument by argument and it worked. So I opened another command line window and tried the same: First "too many arguments", after calling only "pg_dump" and adding further arguments it worked...

4
  • is machine with 9.2.3 is Mac?
    – Alex Stamper
    Commented Jun 6, 2013 at 14:36
  • what are the version of pg_dump's itself (pg_dump --version) on both machines?
    – Alex Stamper
    Commented Jun 6, 2013 at 14:37
  • It is a windows 64 bit machine with postgresql 9.2.3 64bit. I dont know what is wrong, seems like I have to call "pg_dump" without arguments first
    – Anonymous
    Commented Jun 6, 2013 at 14:39
  • Maybe there is an old pg_dump on the path. What does pg_dump --version show?
    – user1822
    Commented Jun 6, 2013 at 14:46

2 Answers 2

4

I'd venture that it has nothing to with pg_dump version but that it may be an invisible spurious character on the command line that is causing this mess. As a demo, if I type this in cmd.exe, it works as expected at first:

pg_dump -U postgres postgres >out.db

But now if I come back on this command with Arrow-Up, position the caret just before the -U option, add a non-breaking space by hitting Alt+255 on the numeric keypad, and validate this command, it yields the error you mention:

pg_dump: too many command-line arguments (first is "-U") Try "pg_dump --help" for more information.

1
  • 1
    ... and in case you're wondering "I didn't type anything like that, what's this got to do with me": You could easily copy and paste such characters, particularly if you're copying from something like MS Word. Commented Jun 6, 2013 at 23:50
0

pg_dump --host <host> --port 5432 --username <login> --format custom --blobs --verbose --file /home/backup/databasename.backup databasename

To run query without asking for password use export PGPASSWORD=your_postgres_password (linux) or SET PGPASSWORD=your_postgres_password (windows)

1
  • How does this solve the problem? The command in the question seems perfectly legit. Commented Jun 14, 2013 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.