Database Backup Plugin Fix + Record Fix
This commit is contained in:
parent
4b94ef29c1
commit
72e6f475d7
@ -26,11 +26,10 @@ class RecordManager{
|
|||||||
};
|
};
|
||||||
|
|
||||||
//Ochrana proti duplicitním hodnotám zapisují se jen změny
|
//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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$record = [
|
$record = [
|
||||||
'execuded' => 1,
|
'execuded' => 1,
|
||||||
|
@ -8,8 +8,8 @@ class DatabaseBackup
|
|||||||
$backupWorker = new DatabaseBackup;
|
$backupWorker = new DatabaseBackup;
|
||||||
$filenames[] = $backupWorker->scheme(); //Backup Database scheme
|
$filenames[] = $backupWorker->scheme(); //Backup Database scheme
|
||||||
$filenames[] = $backupWorker->data(); //Backup Database Data
|
$filenames[] = $backupWorker->data(); //Backup Database Data
|
||||||
$filenames[] = $_SERVER['DOCUMENT_ROOT'] . '/config/config.php'; //Backup Configuration File
|
//$filenames[] = $_SERVER['DOCUMENT_ROOT'] . '/config/config.php'; //Backup Configuration File
|
||||||
$backupWorker->compress($_SERVER['DOCUMENT_ROOT'] . BASEDIR . '/backup/' . date("Y-m-d", time()) . '.zip', $filenames);
|
$backupWorker->compress($_SERVER['DOCUMENT_ROOT'] . BASEDIR . 'backup/' . date("Y-m-d", time()) . '.zip', $filenames);
|
||||||
return 'sucessful';
|
return 'sucessful';
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return 'exception: ' . $e->getMessage();
|
return 'exception: ' . $e->getMessage();
|
||||||
@ -18,7 +18,7 @@ class DatabaseBackup
|
|||||||
|
|
||||||
private function scheme()
|
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";
|
$command = "mysqldump --skip-comments --no-create-info -h localhost -u " . DBUSER . " -p" . DBPASS . " " . DBNAME . " -r $backupfile 2>&1";
|
||||||
$this->executeCommand($command);
|
$this->executeCommand($command);
|
||||||
return $backupfile;
|
return $backupfile;
|
||||||
@ -26,7 +26,7 @@ class DatabaseBackup
|
|||||||
|
|
||||||
private function data()
|
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";
|
$command = "mysqldump --skip-comments --no-data -h localhost -u " . DBUSER . " -p" . DBPASS . " " . DBNAME . " -r $backupfile 2>&1";
|
||||||
$this->executeCommand($command);
|
$this->executeCommand($command);
|
||||||
return $backupfile;
|
return $backupfile;
|
||||||
@ -43,7 +43,9 @@ class DatabaseBackup
|
|||||||
$zip = new ZipArchive();
|
$zip = new ZipArchive();
|
||||||
if ($zip->open($filename, ZipArchive::CREATE | ZipArchive::OVERWRITE)) {
|
if ($zip->open($filename, ZipArchive::CREATE | ZipArchive::OVERWRITE)) {
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
$zip->addFile($file);
|
$filename = explode('/', $file);
|
||||||
|
$filename = end($filename);
|
||||||
|
$zip->addFile($file, $filename);
|
||||||
}
|
}
|
||||||
$zip->close();
|
$zip->close();
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
|
Loading…
Reference in New Issue
Block a user