File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
    Bookmark Topic Watch Topic
  • New Topic

Backup postgres database

 
Pete Dawn
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 33684
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Pete,
Does that command work if you copy/paste it to the DOS/UNIX command line?
 
Pete Dawn
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 33684
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Closing, dupe of this...
 
It is sorta covered in the JavaRanch Style Guide.
    Bookmark Topic Watch Topic
  • New Topic