diff --git a/front/maintenance.php b/front/maintenance.php index cef40efe..bf5c49ec 100644 --- a/front/maintenance.php +++ b/front/maintenance.php @@ -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); +} + + ?>
@@ -62,26 +70,32 @@ exec($execstring, $pia_nmapscans);
last Modification
+
+
DB Backup
+
+
Scan Status (arp)
-
Scans currently running
+
scan(s) currently running
Scan Status (nmap)
-
Scans currently running
+
scan(s) currently running
- + - + - + - + + +
@@ -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?
(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); + }); +} + diff --git a/front/php/server/devices.php b/front/php/server/devices.php index 39585f08..c77494a8 100644 --- a/front/php/server/devices.php +++ b/front/php/server/devices.php @@ -39,6 +39,7 @@ case 'runScan1min': runScan1min(); break; case 'deleteUnknownDevices': deleteUnknownDevices(); break; case 'deleteEvents': deleteEvents(); break; + case 'PiaBackupDBtoArchive': PiaBackupDBtoArchive(); break; case 'getDevicesTotals': getDevicesTotals(); break; @@ -260,7 +261,29 @@ function deleteEvents() { } } +//------------------------------------------------------------------------------ +// Backup DB to Archiv +//------------------------------------------------------------------------------ +function PiaBackupDBtoArchive() { + $file = '/home/pi/pialert/db/pialert.db'; + $newfile = '/home/pi/pialert/db/pialert.db.backup'; + + if (!copy($file, $newfile)) { + echo "Test Function executed not successfully"; + } else { + $Pia_Archive_Name = 'pialertdb_'.date("Ymd_his").'.zip'; + $Pia_Archive_Path = '/home/pi/pialert/db/'; + exec('zip -j '.$Pia_Archive_Path.$Pia_Archive_Name.' /home/pi/pialert/db/pialert.db', $output); + if (file_exists($Pia_Archive_Path.$Pia_Archive_Name)) { + echo 'Test Function executed successfully ('.$Pia_Archive_Name.')'; + } else { + echo 'Test Function executed successfully'; + } + // echo "Test Function executed successfully"; + } + +} //------------------------------------------------------------------------------