-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup.php
132 lines (110 loc) · 5.4 KB
/
backup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
// START SESSION
session_start();
// LOGOUT REQUEST
if (isset($_POST["logout"])) { unset($_SESSION["user"]); }
// REDIRECT TO LOGIN PAGE IF NOT LOGGED IN
if (!isset($_SESSION["user"])) {
header("Location: login.php");
exit();
}
include 'connect.php';
// INCLUDE HEADER FILE
include 'header.php';
// SET BACKUP LOCATION VARIABLE
// TEMP PLACEHOLDER STRING
$backdir = "/mnt/backups";
// CHECK BACKUP DIR CAPACITY AND USAGE
$df = intval(disk_free_space("/") / 1000000000) ;
$ds = intval(disk_total_space("/") / 1000000000) ;
$da = ($ds - $df);
// PULL BACKUP VARIABLES FROM BACKUP.XML
$buxml = simplexml_load_file('/opt/seidr/backup.xml');
$retention=$buxml->retention;
// PAGE CONTENT
echo '
<!-- End of Topbar -->
<!-- Begin Page Content -->
<div class="container-fluid">
<!-- Page Heading -->
<h1 class="h3 mb-4 text-gray-800"></h1>
<!-- Start Locations Card Section -->
<h1>Backup</h1>
<div class="row">
<div class="col-lg-6">
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">Backup Location</h6>
</div>
<div class="card-body">
<p><strong>Current backup location:</strong> ' . $backdir . '
<p><strong>Disk Used:</strong> ' . $da . 'GB / ' . $ds . ' GB<p>
</div>
</div>
</div>
<!-- End Locations Card Section -->
</div>
<!-- Start Schedule Card Section -->
<div class="row">
<div class="col-lg-6">
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">Backup Schedule</h6>
</div>
<div class="card-body">
<strong>Days:</strong><br>
<form action="vm-schedule.php" method="post">
<input type="checkbox" id="sun" name="day[]" value="Sun">
<label for="sun"> Sun</label>
<input type="checkbox" id="mon" name="day[]" value="Mon">
<label for="mon"> Mon</label>
<input type="checkbox" id="tue" name="day[]" value="Tue">
<label for="tues"> Tue</label>
<input type="checkbox" id="wed" name="day[]" value="Wed">
<label for="wed"> Wed</label>
<input type="checkbox" id="thu" name="day[]" value="Thu">
<label for="thurs"> Thu</label>
<input type="checkbox" id="fri" name="day[]" value="Fri">
<label for="fri"> Fri</label>
<input type="checkbox" id="sat" name="day[]" value="Sat">
<label for="sat"> Sat</label>
<hr>
<strong>Time:</strong><br>
<input type="time" id="time" name="time" required>
<hr>
<strong>Retention:</strong><br>
<input type="number" id="retention" name="retention" value=' . $retention . ' required>
<hr>
<button type="submit" class="btn btn-primary">Save</button>
</form>
</div>
</div>
</div>
<!-- End Settings Card Section -->
</div>
<!-- Start Settings Card Section -->
<div class="row">
<div class="col-lg-6">
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">Backup Enabled VMs</h6>
</div>
<div class="card-body">
<table class="table"><thead><tr><th scope="col">Name</th><th scope="col">Size</th></tr></thead><tbody>';
// EXPORT VM LIST AND SIZE DATA
$shellout = shell_exec('/opt/seidr/seidr-info-backup.sh');
echo "$shellout";
echo '
</tbody></table>
</div>
</div>
</div>
<!-- End Settings Card Section -->
</div>
<!-- /.container-fluid -->
</div>
</div>
<!-- End of Main Content -->
';
// INCLUDE HEADER FILE
include 'footer.php';