Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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...

share|improve this question
    
is machine with 9.2.3 is Mac? –  Alex Stamper Jun 6 '13 at 14:36
    
what are the version of pg_dump's itself (pg_dump --version) on both machines? –  Alex Stamper Jun 6 '13 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 Jun 6 '13 at 14:39
    
Maybe there is an old pg_dump on the path. What does pg_dump --version show? –  a_horse_with_no_name Jun 6 '13 at 14:46
add comment

migrated from stackoverflow.com Jun 7 '13 at 4:03

This question came from our site for professional and enthusiast programmers.

2 Answers

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.

share|improve this answer
    
... 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. –  Craig Ringer Jun 6 '13 at 23:50
add comment

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)

share|improve this answer
    
How does this solve the problem? The command in the question seems perfectly legit. –  dezso Jun 14 '13 at 10:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.