Skip to content

Instantly share code, notes, and snippets.

@eos87
Created October 21, 2010 03:46
Show Gist options
  • Save eos87/637897 to your computer and use it in GitHub Desktop.
Save eos87/637897 to your computer and use it in GitHub Desktop.
repaldo postgres desde java
try {
String path = "ruta_donde_repaldar"
Runtime r = Runtime.getRuntime();
//PostgreSQL variables
String user = "postgres";
String dbase = "base_datos";
String password = "tu_clave";
Process p;
ProcessBuilder pb;
/**
* Ejecucion del proceso de respaldo
*/
r = Runtime.getRuntime();
pb = new ProcessBuilder("pg_dump", "-v", "-D", "-f", path, "-U", user, dbase);
pb.environment().put("PGPASSWORD", password);
pb.redirectErrorStream(true);
p = pb.start();
} catch (Exception e) {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment