Merge branch 'remastering' of https://git.steelants.cz/SH/PHP_SMART_HOME_V3 into remastering

This commit is contained in:
Haitem 2021-01-05 12:19:41 +01:00
commit d9952a59fb

View File

@ -9,24 +9,24 @@ class 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();
} }
} }
private function scheme() private function data()
{ {
$backupfile = $_SERVER['DOCUMENT_ROOT'] . BASEDIR . "backup/" . DBNAME . '_scheme_' . 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-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;
} }
private function data() private function scheme()
{ {
$backupfile = $_SERVER['DOCUMENT_ROOT'] . BASEDIR . "backup/" . DBNAME . '_data_' . 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-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,9 +43,7 @@ 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) {
$filename = explode('/', $file); $zip->addFile($file);
$filename = end($filename);
$zip->addFile($file, $filename);
} }
$zip->close(); $zip->close();
foreach ($files as $file) { foreach ($files as $file) {