backup.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. $msg = "";
  3. if ( ($_SERVER["REQUEST_METHOD"] == "POST") && ( isset($_POST["disks"]) ) ){
  4. $msg = "Scheduled incremental Backup for disk(s): ";
  5. $pipe = popen('bconsole -c /var/www/bconsole.conf 2>&1 > /tmp/feedback', 'w');
  6. #2017-06-02 15:02:43
  7. $date = date('Y-m-d G:i:s', time()+60);
  8. # Schedule backup with bareos
  9. foreach ($_POST["disks"] as $backup) {
  10. if ( preg_match("/hdd\d+/", $backup) ){
  11. $msg .= "$backup, ";
  12. $cmd = "run job=\"Backup_archivo_to_LTO7\" fileset=\"archivo $backup\" level=\"Incremental\" client=\"archivo-fd\" pool=\"Incremental\" storage=\"LTO7\" priority=10 when=\"$date\" yes\n\r";
  13. fwrite($pipe, $cmd, strlen($cmd));
  14. #$msg .= $cmd;
  15. }
  16. }
  17. $msg .= "\n\r<br/>";
  18. pclose($pipe);
  19. } else {
  20. unset ($msg);
  21. }
  22. ?>
  23. <html>
  24. <head>
  25. <title>Deviproductions LTO7 Backup</title>
  26. <style type="text/css">
  27. form { display: table; background-image:url('pics/background.png'); padding:20px; border:4px solid #ddd; width: 200px; height: 300px }
  28. td, input, select, textarea { font-size:13px; font-family:Verdana,sans-serif; font-weight:bold; }
  29. input, select, textarea { color:#00c; }
  30. input { width: 190px; border: 2px solid black; border-radius: 4px; }
  31. select {
  32. width: 190px;
  33. height: 300px;
  34. box-sizing: border-box;
  35. border: 2px solid #ccc;
  36. border-radius: 10px;
  37. font-size: 16px;
  38. background-color: white;
  39. background-image: url('pics/hdd03.png');
  40. background-position: -2px 2px;
  41. background-repeat: no-repeat;
  42. padding: 5px 10px 5px 50px;
  43. }
  44. div {float: left;}
  45. .left, .right {display: table-cell}
  46. </style>
  47. <script type="text/javascript">
  48. function selectAll(selectBox,selectAll) {
  49. // have we been passed an ID
  50. if (typeof selectBox == "string") {
  51. selectBox = document.getElementById(selectBox);
  52. }
  53. // is the select box a multiple select box?
  54. if (selectBox.type == "select-multiple") {
  55. for (var i = 0; i < selectBox.options.length; i++) {
  56. selectBox.options[i].selected = selectAll;
  57. }
  58. }
  59. }
  60. </script>
  61. </head>
  62. <body>
  63. <?php
  64. if ( isset($msg) ) {
  65. print "<div>$msg</div>";
  66. }
  67. ?>
  68. <h1>incremental Backup</h1>
  69. <form action="backup.php" method="post">
  70. <input type="hidden" name="type" value="incremental">
  71. <div class="left">
  72. <select id="selectbox" name="disks[]" multiple>
  73. <?php
  74. for ($i=1;$i<=20;$i++){
  75. $disk = sprintf("hdd%02d", $i);
  76. echo "<option value=\"$disk\">$disk</option>";
  77. }
  78. ?>
  79. </select>
  80. </div>
  81. <div class="right">
  82. <input type="button" name="Button" value="alle ausw&auml;hlen" onclick="selectAll('selectbox',true)" />
  83. <input type="button" name="Button" value="keine ausw&auml;hlen" onclick="selectAll('selectbox',false)" />
  84. <input type="submit" value="backup">
  85. <div/>
  86. </form>
  87. <div class="2row">
  88. </div>
  89. </body>
  90. </html>