Database Backup Plugin Fix + Record Fix

This commit is contained in:
GamerClassN7 2020-11-01 21:20:05 +01:00
parent 4b94ef29c1
commit 72e6f475d7
2 changed files with 8 additions and 7 deletions

View File

@ -26,10 +26,9 @@ class RecordManager{
};
//Ochrana proti duplicitním hodnotám zapisují se jen změny
if (self::getLastRecord($subDeviceId, 1)['value'] === $value){
if (self::getLastRecord($subDeviceId, 1)['value'] == $value){
return false;
}
try {
$record = [

View File

@ -8,8 +8,8 @@ class DatabaseBackup
$backupWorker = new DatabaseBackup;
$filenames[] = $backupWorker->scheme(); //Backup Database scheme
$filenames[] = $backupWorker->data(); //Backup Database Data
$filenames[] = $_SERVER['DOCUMENT_ROOT'] . '/config/config.php'; //Backup Configuration File
$backupWorker->compress($_SERVER['DOCUMENT_ROOT'] . BASEDIR . '/backup/' . date("Y-m-d", time()) . '.zip', $filenames);
//$filenames[] = $_SERVER['DOCUMENT_ROOT'] . '/config/config.php'; //Backup Configuration File
$backupWorker->compress($_SERVER['DOCUMENT_ROOT'] . BASEDIR . 'backup/' . date("Y-m-d", time()) . '.zip', $filenames);
return 'sucessful';
} catch (Exception $e) {
return 'exception: ' . $e->getMessage();
@ -18,7 +18,7 @@ class DatabaseBackup
private function scheme()
{
$backupfile = $_SERVER['DOCUMENT_ROOT'] . BASEDIR . "/backup/" . DBNAME . '_scheme_' . date("Y-m-d", time()) . '.sql';
$backupfile = $_SERVER['DOCUMENT_ROOT'] . BASEDIR . "backup/" . DBNAME . '_scheme_' . date("Y-m-d", time()) . '.sql';
$command = "mysqldump --skip-comments --no-create-info -h localhost -u " . DBUSER . " -p" . DBPASS . " " . DBNAME . " -r $backupfile 2>&1";
$this->executeCommand($command);
return $backupfile;
@ -26,7 +26,7 @@ class DatabaseBackup
private function data()
{
$backupfile = $_SERVER['DOCUMENT_ROOT'] . BASEDIR . "/backup/" . DBNAME . '_data_' . date("Y-m-d", time()) . '.sql';
$backupfile = $_SERVER['DOCUMENT_ROOT'] . BASEDIR . "backup/" . DBNAME . '_data_' . date("Y-m-d", time()) . '.sql';
$command = "mysqldump --skip-comments --no-data -h localhost -u " . DBUSER . " -p" . DBPASS . " " . DBNAME . " -r $backupfile 2>&1";
$this->executeCommand($command);
return $backupfile;
@ -43,7 +43,9 @@ class DatabaseBackup
$zip = new ZipArchive();
if ($zip->open($filename, ZipArchive::CREATE | ZipArchive::OVERWRITE)) {
foreach ($files as $file) {
$zip->addFile($file);
$filename = explode('/', $file);
$filename = end($filename);
$zip->addFile($file, $filename);
}
$zip->close();
foreach ($files as $file) {