backup.php 3.0 KB

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