Add DB Backup to Maintenance fix

relative paths
This commit is contained in:
leiweibau
2022-06-22 09:14:42 +02:00
parent 4bf5dfb8b1
commit 2d1ccf0e19
2 changed files with 6 additions and 5 deletions

View File

@@ -47,7 +47,7 @@ $execstring = 'ps -f -u pi | grep "nmap" 2>&1';
$pia_nmapscans = "";
exec($execstring, $pia_nmapscans);
$Pia_Archive_Path = "/home/pi/pialert/db/";
$Pia_Archive_Path = str_replace('front', 'db', getcwd()).'/';
$Pia_Archive_count = 0;
$files = glob($Pia_Archive_Path . "*.zip");
if ($files){

View File

@@ -266,15 +266,16 @@ function deleteEvents() {
//------------------------------------------------------------------------------
function PiaBackupDBtoArchive() {
$file = '/home/pi/pialert/db/pialert.db';
$newfile = '/home/pi/pialert/db/pialert.db.backup';
// $DBFILE = '../../../db/pialert.db';
$file = '../../../db/pialert.db';
$newfile = '../../../db/pialert.db.backup';
if (!copy($file, $newfile)) {
echo "Test Function executed not successfully";
} else {
$Pia_Archive_Name = 'pialertdb_'.date("Ymd_his").'.zip';
$Pia_Archive_Path = '/home/pi/pialert/db/';
exec('zip -j '.$Pia_Archive_Path.$Pia_Archive_Name.' /home/pi/pialert/db/pialert.db', $output);
$Pia_Archive_Path = '../../../db/';
exec('zip -j '.$Pia_Archive_Path.$Pia_Archive_Name.' ../../../db/pialert.db', $output);
if (file_exists($Pia_Archive_Path.$Pia_Archive_Name)) {
echo 'Test Function executed successfully ('.$Pia_Archive_Name.')';
} else {