mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 01:26:11 -08:00
maintenance task
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
|
||||
<!-- Content header--------------------------------------------------------- -->
|
||||
<section class="content-header">
|
||||
<?php require 'php/templates/notification.php'; ?>
|
||||
<h1 id="pageTitle">
|
||||
Maintenance tools
|
||||
</h1>
|
||||
@@ -37,6 +38,20 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12">
|
||||
<div class="pull-right">
|
||||
<button type="button" class="btn btn-default pa-btn pa-btn-create" style="margin-left:0px;"
|
||||
id="btnBackup" onclick="askCreateBackupDB()"> Backup DB </button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12">
|
||||
<div class="pull-right">
|
||||
<button type="button" class="btn btn-default pa-btn pa-btn-delete" style="margin-left:0px;"
|
||||
id="btnRestore" onclick="askRestoreBackupDB()"> Restore DB </button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ----------------------------------------------------------------------- -->
|
||||
</section>
|
||||
<!-- /.content -->
|
||||
@@ -53,7 +68,8 @@
|
||||
<script>
|
||||
function askDeleteDevicesWithEmptyMACs () {
|
||||
// Ask delete device
|
||||
showModalWarning ('Delete Devices', 'Are you sure you want to delete all devices with empty MAC addresses?<br>(maybe you prefer to archive it)',
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
@@ -65,6 +81,51 @@ function deleteDevicesWithEmptyMACs()
|
||||
showMessage (msg);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// DB backup
|
||||
|
||||
function askCreateBackupDB () {
|
||||
// Ask delete device
|
||||
|
||||
showModalWarning('Backup DB', 'This creates a pialert.db_bak file in the /config folder',
|
||||
'Cancel', 'Create', 'createBackupDB');
|
||||
}
|
||||
|
||||
|
||||
function createBackupDB()
|
||||
{
|
||||
// Delete device
|
||||
$.get('php/server/devices.php?action=createBackupDB', function(msg) {
|
||||
showMessage (msg);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// DB restore
|
||||
|
||||
function askRestoreBackupDB () {
|
||||
// Ask delete device
|
||||
|
||||
showModalWarning('Restore DB', 'This restores a pialert.db_bak file from the /config folder',
|
||||
'Cancel', 'Restore', 'restoreBackupDB');
|
||||
}
|
||||
|
||||
|
||||
function restoreBackupDB()
|
||||
{
|
||||
// Delete device
|
||||
$.get('php/server/devices.php?action=restoreBackupDB', function(msg) {
|
||||
showMessage (msg);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
<!--
|
||||
|
||||
Reference in New Issue
Block a user