It's the first time I try to make a backup of a BD Mysql
from a JSP
This is my code (In some forum I saw it).
<%@page import="java.sql.*" %>
<%@page import ="java.util.Calendar" %>
<%
try{
Calendar fecha = Calendar.getInstance();
String fechaHoy = fecha.get(Calendar.DATE)+"-"+fecha.get(Calendar.MONTH)+"-"+fecha.get(Calendar.YEAR);
String nombre = "Respaldo_Sistema_"+fechaHoy+".sql";
int copia_seguridad;
Process runtimeProcess = Runtime.getRuntime().exec("C:/xampp/mysql/bin/mysqldump.exe --opt --password='' --user=root --databases seapto2 -r C:/"+nombre);
copia_seguridad = runtimeProcess.waitFor();
if(copia_seguridad==0){ //Devuelve 0 si todo ha salido bien
%> <script>
function respaldoRealizado() {
alert("El respaldo ha sido creado con exito.\n\nCompruebe la ubicacion del archivo en el disco local \nC:");
location.href="inicio.jsp";
}
respaldoRealizado();
</script>
<%
} else {
%> <script>
function respaldoNoRealizado() {
alert("El respaldo no se pudo generar");
location.href="inicio.jsp";
}
respaldoNoRealizado();
</script>
<%
}
} catch(Exception e){
out.println(e);
}
%>
The problem is that it does not generate any errors, but neither does it generate the backup
...
Any ideas ??