Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@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.nnCompruebe 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);
- }
- %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement