From 496e8ad2b7f7494172e63f999ec6872de7e91348 Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Fri, 14 Jan 2022 14:11:08 +1100 Subject: [PATCH] maintenance task --- front/maintenance.php | 63 +++++++++++++++++++++++++++++++++- front/php/server/devices.php | 34 ++++++++++++++++++ front/php/templates/header.php | 2 +- 3 files changed, 97 insertions(+), 2 deletions(-) diff --git a/front/maintenance.php b/front/maintenance.php index de350f84..cad959fc 100644 --- a/front/maintenance.php +++ b/front/maintenance.php @@ -21,6 +21,7 @@
+

Maintenance tools

@@ -37,6 +38,20 @@ +
+
+ +
+
+ +
+
+ +
+
+
@@ -53,7 +68,8 @@ diff --git a/front/php/server/devices.php b/front/php/server/devices.php index 08a7f8f7..33582593 100644 --- a/front/php/server/devices.php +++ b/front/php/server/devices.php @@ -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 diff --git a/front/php/templates/header.php b/front/php/templates/header.php index eae9305a..22204f33 100644 --- a/front/php/templates/header.php +++ b/front/php/templates/header.php @@ -170,7 +170,7 @@
  • - Maintenance + Maintenance