mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
Add DB Backup to Maintenance
Added the possibility to perform a backup of the database. This creates a "pending" backup (a copy of the database) and from it an archive with the current date. The "pending" backup is overwritten with the next backup. The status information on the maintenance page has been supplemented accordingly.
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
|
||||
$pia_db = str_replace('front', 'db', getcwd()).'/pialert.db';
|
||||
//echo $pia_db;
|
||||
$pia_db_size = number_format(filesize($pia_db),2,",",".") . ' Byte';
|
||||
$pia_db_size = number_format(filesize($pia_db),0,",",".") . ' Byte';
|
||||
//echo $pia_db_size;
|
||||
$pia_db_mod = date ("F d Y H:i:s", filemtime($pia_db));
|
||||
|
||||
@@ -47,6 +47,14 @@ $execstring = 'ps -f -u pi | grep "nmap" 2>&1';
|
||||
$pia_nmapscans = "";
|
||||
exec($execstring, $pia_nmapscans);
|
||||
|
||||
$Pia_Archive_Path = "/home/pi/pialert/db/";
|
||||
$Pia_Archive_count = 0;
|
||||
$files = glob($Pia_Archive_Path . "*.zip");
|
||||
if ($files){
|
||||
$Pia_Archive_count = count($files);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<div class="table">
|
||||
@@ -62,26 +70,32 @@ exec($execstring, $pia_nmapscans);
|
||||
<div class="table-cell">last Modification</div>
|
||||
<div class="table-cell"><?php echo $pia_db_mod;?></div>
|
||||
</div>
|
||||
<div class="table-row">
|
||||
<div class="table-cell">DB Backup</div>
|
||||
<div class="table-cell"><?php echo $Pia_Archive_count.' Backups where found';?></div>
|
||||
</div>
|
||||
<div class="table-row">
|
||||
<div class="table-cell">Scan Status (arp)</div>
|
||||
<div class="table-cell"><?php echo sizeof($pia_arpscans);?> Scans currently running</div>
|
||||
<div class="table-cell"><?php echo sizeof($pia_arpscans);?> scan(s) currently running</div>
|
||||
</div>
|
||||
<div class="table-row">
|
||||
<div class="table-cell">Scan Status (nmap)</div>
|
||||
<div class="table-cell"><?php echo sizeof($pia_nmapscans);?> Scans currently running</div>
|
||||
<div class="table-cell"><?php echo sizeof($pia_nmapscans);?> scan(s) currently running</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-xs-12" style="text-align:center; padding-top: 10px; margin-bottom: 50px;">
|
||||
|
||||
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnDeleteMAC" style="border-top: solid 3px #dd4b39;" onclick="askDeleteDevicesWithEmptyMACs()">Delete Devices with empty MACs</button>
|
||||
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnDeleteMAC" style="border-top: solid 3px #dd4b39;" onclick="askDeleteDevicesWithEmptyMACs()">Delete Devices with empty MACs</button>
|
||||
|
||||
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnDeleteMAC" style="border-top: solid 3px #dd4b39;" onclick="askDeleteAllDevices()">Delete All Devices</button>
|
||||
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnDeleteMAC" style="border-top: solid 3px #dd4b39;" onclick="askDeleteAllDevices()">Delete All Devices</button>
|
||||
|
||||
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnDeleteUnknown" style="border-top: solid 3px #dd4b39;" onclick="askDeleteUnknown()">Delete (unknown) Devices</button>
|
||||
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnDeleteUnknown" style="border-top: solid 3px #dd4b39;" onclick="askDeleteUnknown()">Delete (unknown) Devices</button>
|
||||
|
||||
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnDeleteEvents" style="border-top: solid 3px #dd4b39;" onclick="askDeleteEvents()">Delete all Events (Reset Presence)</button>
|
||||
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnDeleteEvents" style="border-top: solid 3px #dd4b39;" onclick="askDeleteEvents()">Delete all Events (Reset Presence)</button>
|
||||
|
||||
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnPiaBackupDBtoArchive" style="border-top: solid 3px #dd4b39;" onclick="askPiaBackupDBtoArchive()">Execute DB Backup</button>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -104,7 +118,7 @@ exec($execstring, $pia_nmapscans);
|
||||
|
||||
// delete devices with emty macs
|
||||
|
||||
function askDeleteDevicesWithEmptyMACs () {
|
||||
function askDeleteDevicesWithEmptyMACs () {
|
||||
// Ask
|
||||
showModalWarning('Delete Devices', 'Are you sure you want to delete all devices with empty MAC addresses?<br>(maybe you prefer to archive it)',
|
||||
'Cancel', 'Delete', 'deleteDevicesWithEmptyMACs');
|
||||
@@ -168,6 +182,22 @@ function deleteEvents()
|
||||
}
|
||||
|
||||
|
||||
// Backup DB to Archive
|
||||
function askPiaBackupDBtoArchive () {
|
||||
// Ask
|
||||
showModalWarning('DB Backup', 'Are you sure you want to exectute the the DB Backup? Be sure that no scan is currently running.',
|
||||
'Cancel', 'Run Backup', 'PiaBackupDBtoArchive');
|
||||
}
|
||||
|
||||
|
||||
function PiaBackupDBtoArchive()
|
||||
{
|
||||
// Execute
|
||||
$.get('php/server/devices.php?action=PiaBackupDBtoArchive', function(msg) {
|
||||
showMessage (msg);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user