From 97cfb84bdc7ea6b23dabb1cae243851465a3685c Mon Sep 17 00:00:00 2001
From: leiweibau <105860611+leiweibau@users.noreply.github.com>
Date: Wed, 22 Jun 2022 08:58:55 +0200
Subject: [PATCH] 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.
---
front/maintenance.php | 46 +++++++++++++++++++++++++++++-------
front/php/server/devices.php | 23 ++++++++++++++++++
2 files changed, 61 insertions(+), 8 deletions(-)
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);
+}
+
+
?>