maintenance task

This commit is contained in:
jokob-sk
2022-01-14 14:11:08 +11:00
parent 2488151757
commit 496e8ad2b7
3 changed files with 97 additions and 2 deletions

View File

@@ -32,6 +32,9 @@
case 'setDeviceData': setDeviceData(); break;
case 'deleteDevice': deleteDevice(); break;
case 'deleteAllWithEmptyMACs': deleteAllWithEmptyMACs(); break;
case 'createBackupDB': createBackupDB(); break;
case 'restoreBackupDB': restoreBackupDB(); break;
case 'getDevicesTotals': getDevicesTotals(); break;
@@ -195,6 +198,37 @@ function deleteAllWithEmptyMACs() {
}
//------------------------------------------------------------------------------
// Create a DB backup
//------------------------------------------------------------------------------
function createBackupDB() {
//
$result = copy("/home/pi/pialert/db/pialert.db","/home/pi/pialert/config/pialert.db_bak");
// check result
if ($result == TRUE) {
echo "Copied successfully";
} else {
echo "Error copying DB. SSH into instance and copy manually.";
}
}
//------------------------------------------------------------------------------
// Restore latest DB backup
//------------------------------------------------------------------------------
function restoreBackupDB() {
//
$result = copy("/home/pi/pialert/config/pialert.db_bak", "/home/pi/pialert/db/pialert.db");
// check result
if ($result == TRUE) {
echo "Copied successfully";
} else {
echo "Error copying DB. SSH into instance and copy manually.";
}
}
//------------------------------------------------------------------------------
// Query total numbers of Devices by status

View File

@@ -170,7 +170,7 @@
</li>
<li class=" <?php if (in_array (basename($_SERVER['SCRIPT_NAME']), array('maintenance.php') ) ){ echo 'active'; } ?>">
<a href="maintenance.php"><i class="fa fa-bolt"></i> <span>Maintenance</span></a>
<a href="maintenance.php"><i class="fa fa-cog fa-spin fa-3x fa-fw"></i> <span>Maintenance</span></a>
</li>
<!--