Advertisement
Guest User

Untitled

a guest
Apr 19th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. <%@page import="java.sql.*" %>
  2. <%@page import ="java.util.Calendar" %>
  3. <%
  4. try{
  5. Calendar fecha = Calendar.getInstance();
  6. String fechaHoy = fecha.get(Calendar.DATE)+"-"+fecha.get(Calendar.MONTH)+"-"+fecha.get(Calendar.YEAR);
  7. String nombre = "Respaldo_Sistema_"+fechaHoy+".sql";
  8. int copia_seguridad;
  9.  
  10. Process runtimeProcess = Runtime.getRuntime().exec("C:/xampp/mysql/bin/mysqldump.exe --opt --password='' --user=root --databases seapto2 -r C:/"+nombre);
  11.  
  12. copia_seguridad = runtimeProcess.waitFor();
  13.  
  14. if(copia_seguridad==0){ //Devuelve 0 si todo ha salido bien
  15. %> <script>
  16. function respaldoRealizado() {
  17. alert("El respaldo ha sido creado con exito.nnCompruebe la ubicacion del archivo en el disco local nC:");
  18. location.href="inicio.jsp";
  19. }
  20. respaldoRealizado();
  21. </script>
  22. <%
  23. } else {
  24. %> <script>
  25. function respaldoNoRealizado() {
  26. alert("El respaldo no se pudo generar");
  27. location.href="inicio.jsp";
  28. }
  29. respaldoNoRealizado();
  30. </script>
  31. <%
  32. }
  33.  
  34. } catch(Exception e){
  35. out.println(e);
  36. }
  37. %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement