我已经编写了Java代码来获取POSTGRESQL,但程序执行正常而没有错误,p.exitValue()返回Zero.But备份文件没有创建.Below是代码
Runtime rt = Runtime.getRuntime();
Process p;
ProcessBuilder pb;
rt = Runtime.getRuntime();
pb = new ProcessBuilder(
"/home/Java Softwares/postgres_setup/pgsql/bin/pg_dump",
"--version", "9.2.18",
"--host", "2BrigHQ",
"--port", "5432",
"--username", "postgres",
"--no-password",
"--dbname", "postfixdb",
"--format", "plain",
"--blobs",
"--verbose",
"--file",
"/usr/backup/" + backupdate + "_pg_backup.sql");
try {
final Map < String, String > env = pb.environment();
env.put("PGPASSWORD", "admin");
p = pb.start();
final BufferedReader r = new BufferedReader(
new InputStreamReader(p.getErrorStream()));
String line = r.readLine();
while (line != null) {
System.err.println(line);
line = r.readLine();
}
r.close();
p.waitFor();
System.out.println(p.exitValue());
System.out.println("backup successfull");
} catch (IOException | InterruptedException e) {
System.out.println(e.getMessage());
}