Created
October 21, 2010 03:46
-
-
Save eos87/637897 to your computer and use it in GitHub Desktop.
repaldo postgres desde java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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