Update UpdateSoftwareCommand.php

This commit is contained in:
M011N1N6 2025-03-06 04:13:14 +03:30 committed by GitHub
parent 6de0c1eeb5
commit 86fedf3f35
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,6 +1,5 @@
<?php
namespace App\Command;
use Symfony\Component\Console\Attribute\AsCommand;
@ -289,9 +288,9 @@ class UpdateSoftwareCommand extends Command
}
private function backupDatabase(): string
{
{
$backupFile = $this->backupDir . '/db_backup_' . time() . '.sql';
$dbUrl = $this->params->get('DATABASE_URL');
$dbUrl = $this->params->get('database_url');
$urlParts = parse_url($dbUrl);
$dbHost = $urlParts['host'] ?? 'localhost';
@ -304,18 +303,20 @@ class UpdateSoftwareCommand extends Command
'-h', $dbHost,
'-u', $dbUser,
'-p' . $dbPass,
$dbName,
'>',
$backupFile
$dbName
];
$this->runProcess($command, $this->rootDir, new \Symfony\Component\Console\Output\NullOutput());
if (!file_exists($backupFile)) {
$process = new Process($command, $this->rootDir);
$process->setTimeout(3600);
$process->mustRun();
file_put_contents($backupFile, $process->getOutput());
if (!file_exists($backupFile) || filesize($backupFile) === 0) {
throw new \RuntimeException('Failed to create database backup.');
}
$this->logger->info("Database backup created at: $backupFile");
return $backupFile;
}
}
private function backupArchive(): string
{