Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I want to do a backup and restore of postgres database via java application.
The restore function work perfect using processBuilder but when I want to do the same thing for the restore function I get this error:
pg_basebackup: « = » missing after « certificat_test » in the connection parameters string
and this is my code :

Process p;
ProcessBuilder pb;
Runtime r = Runtime.getRuntime();
String pcUser = System.getProperty("user.name");

pb = new ProcessBuilder("C:/Program Files/PostgreSQL/9.3/bin/pg_basebackup.exe",
                        "-d", "certificat_test",
                        "-h", "127.0.0.1",
                        "-p", "5432",
                        "-U", "postgres",                               
                        "-D","C:\\Users\\"+pcUser+"\\Desktop\\test.backup"); 

pb.redirectErrorStream(true);
try {
    p = pb.start();

    InputStream is = p.getInputStream();
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);
    String ll;
    while ((ll = br.readLine()) != null) {
     System.out.println(ll);
    } 
    int res = p.waitFor();
    JOptionPane.showMessageDialog(null, "Process Stat: "+res);
}catch (InterruptedException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
    JOptionPane.showMessageDialog(null, e.getMessage());
}


Thanks for help.

share|improve this question

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.