From 0120d3f2267d2b012800722541e371e43ebc1d99 Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Fri, 14 Jan 2022 14:48:42 +1100 Subject: [PATCH] maintenance task DB --- back/maintenance.py | 23 ++++++++++++ front/maintenance.php | 60 ++++++++++++++++++++++++------ front/php/server/devices.php | 71 ++++++++++++++++++++++++++++-------- 3 files changed, 126 insertions(+), 28 deletions(-) create mode 100644 back/maintenance.py diff --git a/back/maintenance.py b/back/maintenance.py new file mode 100644 index 00000000..07422d1e --- /dev/null +++ b/back/maintenance.py @@ -0,0 +1,23 @@ +import sys +import shutil + + +def main (): + + argument = str(sys.argv[1]) + + ## Main Commands + if argument == 'backup_db': + res = backup_db() + + if argument == 'restore_db': + res = restore_db() + +def backup_db (): + # Header + shutil.copyfile("/home/pi/pialert/db/pialert.db", "/home/pi/pialert/config/pialert.db_bak") + + +def restore_db (): + # Header + shutil.copyfile("/home/pi/pialert/config/pialert.db_bak", "/home/pi/pialert/db/pialert.db") \ No newline at end of file diff --git a/front/maintenance.php b/front/maintenance.php index 6fd97a09..267f087d 100644 --- a/front/maintenance.php +++ b/front/maintenance.php @@ -36,28 +36,28 @@ - - -
+
- + +
+ +
+
-
- + + + @@ -73,6 +73,9 @@