This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
    Bookmark Topic Watch Topic
  • New Topic

Backup postgres database

 
Pete Dawn
Greenhorn
Posts: 17
  • 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: 34095
337
Eclipse IDE Java VI Editor
  • 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
  • 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: 34095
337
Eclipse IDE Java VI Editor
  • 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: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Closing, dupe of this...
 
    Bookmark Topic Watch Topic
  • New Topic