File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Backup postgres database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic
Author

Backup postgres database

Pete Dawn
Greenhorn

Joined: Sep 28, 2006
Posts: 17
guys,

I am trying to implement a postgres DB backup function from within my web application. Now so far I have got this,
Process p = Runtime.getRuntime().exec( new String[] {
"cmd.exe",
"/E:1900",
"/C",
"C:\\Program Files\\postgresql\\8.1\\bin\\pg_dump -i -h localhost -p 5432 -U postgres -F t -b -v -f C:\\Test.backup TESTDB"});

But it isnt working. I am constantly getting an error that c:\program location does not exist, i guess thats coz program files has a space in it.

Can somebody please give me the right syntax (right way) of performing this function.

Thanks.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30913
    
158

Pete,
Does that command work if you copy/paste it to the DOS/UNIX command line?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Pete Dawn
Greenhorn

Joined: Sep 28, 2006
Posts: 17
yes the command works from the command line standalone. but i am not sure how to run it from within my java code. i am sure that my command is correct, my syntax for using that command is incorrect.

any help.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30913
    
158

I'm going to move this to our Java In General forum for you since the question isn't specific to JDBC.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Closing, dupe of this...


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Backup postgres database