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.