diff --git a/scripts/local/backup_local_database.sh b/scripts/local/backup_local_database.sh index 5d09a7f..2cb472f 100644 --- a/scripts/local/backup_local_database.sh +++ b/scripts/local/backup_local_database.sh @@ -27,3 +27,7 @@ chmod -R 0777 "$to_path" BACKUP_TEMP_FILE="$to_path/database_migration.sql" mysqldump --no-tablespaces "$ignoredTables" -u "$user" -p"$password" -h"$host" -P"$port" "$database" > "$BACKUP_TEMP_FILE" + +# Das hier ist der exit Code vom vorherigen Befehl +exitCode=$? +exit $exitCode \ No newline at end of file diff --git a/src/Logic/Compressor.php b/src/Logic/Compressor.php index 2e59849..43873ff 100644 --- a/src/Logic/Compressor.php +++ b/src/Logic/Compressor.php @@ -40,7 +40,7 @@ public function compress(string $directory, string $compressedFile, string $name shell_exec("bash $archiveScriptPath -f \"$directory\" -t \"$compressedFile\" -n \"$name\""); $this->_poller->pollFile( $this->_path. ConstantsTestStage::LOCAL_DIRECTORY. "/$name"); }catch (Exception $e) { - throw new Compress("Failed to compress to: \"$compressedFile\". $e"); + throw new Compress("Failed to compress to: \"$compressedFile\".\nException message: $e"); } } } diff --git a/src/Logic/Database/Migrator/DatabaseMigrationBuilder.php b/src/Logic/Database/Migrator/DatabaseMigrationBuilder.php index f4ec78b..21436b2 100644 --- a/src/Logic/Database/Migrator/DatabaseMigrationBuilder.php +++ b/src/Logic/Database/Migrator/DatabaseMigrationBuilder.php @@ -69,14 +69,18 @@ public function buildAndCopy(): string } /** - * @throws BuildDatabaseMigration + * @throws BuildDatabaseMigration|Exception */ private function createMigrationFile(): string { $ignoredTables = $this->getIgnoreTablesAsString(); - $debugMessage = date("H:i:s:u") . " migration ignore tables: " . implode(",", $ignoredTables) . "\n"; - shell_exec("bash " . $this->_path . ConstantsTestStage::BACKUP_LOCAL_DATABASE . " -i'".$ignoredTables."' -u'".$this->_testDatabaseConfig->getUsername()."' -p'".$this->_testDatabaseConfig->getPassword()."' -h'".$this->_testDatabaseConfig->getServer()."' -P'".$this->_testDatabaseConfig->getPort()."' -d'".$this->_testDatabaseConfig->getName()."' -t'" . $this->_path . ConstantsTestStage::DATABASE_MIGRATION_DIRECTORY . "' 2>&1"); - $debugMessage .= date("H:i:s:u") . " backuped local database \n"; + $debugMessage = date("H:i:s:u") . " migration ignore tables: " . $ignoredTables . "\n"; + $exitCode = shell_exec("bash " . $this->_path . ConstantsTestStage::BACKUP_LOCAL_DATABASE . " -i'".$ignoredTables."' -u'".$this->_testDatabaseConfig->getUsername()."' -p'".$this->_testDatabaseConfig->getPassword()."' -h'".$this->_testDatabaseConfig->getServer()."' -P'".$this->_testDatabaseConfig->getPort()."' -d'".$this->_testDatabaseConfig->getName()."' -t'" . $this->_path . ConstantsTestStage::DATABASE_MIGRATION_DIRECTORY . "' 2>&1"); + if($exitCode != 0) { + throw new Exception("Failed to create local database backup. Output: $exitCode"); + } else { + $debugMessage .= date("H:i:s:u") . " backuped local database \n"; + } return $debugMessage; }