CodeRabbit fixes, again.

This commit is contained in:
Mahad Kalam 2025-12-10 19:48:27 +00:00 committed by Andras Bacsai
parent 556ced24b5
commit b20510a8b1
3 changed files with 24 additions and 12 deletions

View file

@ -26,6 +26,7 @@ use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
use RuntimeException;
use Throwable;
use Visus\Cuid2\Cuid2;
@ -822,7 +823,7 @@ class DatabaseBackupJob implements ShouldBeEncrypted, ShouldQueue
$config = PgBackrestService::generateConfig($this->database);
if ($config === null) {
throw new \Exception('No valid pgBackRest repository configured. Please configure at least one repository (local or S3).');
throw new RuntimeException('No valid pgBackRest repository configured. Please configure at least one repository (local or S3).');
}
$configBase64 = base64_encode($config);

View file

@ -400,7 +400,7 @@ class PgBackrestRestoreJob implements ShouldBeEncrypted, ShouldQueue
$sidecarName = 'pgbackrest-restore-'.$this->database->uuid.'-'.time();
$fullRestoreScript = $this->getInstallAndRunCommand($restoreCmd).' && chown -R 999:999 '.PgBackrestService::PGDATA_PATH;
$fullRestoreScript = $this->getInstallAndRunCommand($restoreCmd);
$cmd = sprintf(
'docker run --rm --name %s --network %s %s %s %s sh -c \'%s\' 2>&1',

View file

@ -9,6 +9,7 @@ use App\Models\StandalonePostgresql;
use Exception;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Livewire\Attributes\Locked;
use Livewire\Attributes\Validate;
@ -133,6 +134,14 @@ class BackupEdit extends Component
*/
public function togglePgbackrestEngine(): void
{
$this->authorize('update', $this->backup->database);
if (! $this->isPostgresql()) {
$this->engine = 'native';
return;
}
$this->engine = $this->engine === 'pgbackrest' ? 'native' : 'pgbackrest';
}
@ -157,18 +166,20 @@ class BackupEdit extends Component
$this->backup->timeout = $this->timeout;
if ($this->engine === 'pgbackrest') {
$this->backup->save_s3 = $this->saveS3;
$this->backup->disable_local_backup = $this->saveS3 && $this->disableLocalBackup;
DB::transaction(function () {
$this->backup->save_s3 = $this->saveS3;
$this->backup->disable_local_backup = $this->saveS3 && $this->disableLocalBackup;
$this->backup->pgbackrest_backup_type = $this->pgbackrestBackupType;
$this->backup->pgbackrest_compress_type = $this->pgbackrestCompressType;
$this->backup->pgbackrest_compress_level = $this->pgbackrestCompressLevel;
$this->backup->pgbackrest_log_level = $this->pgbackrestLogLevel;
$this->backup->pgbackrest_archive_mode = $this->pgbackrestArchiveMode;
$this->backup->pgbackrest_backup_type = $this->pgbackrestBackupType;
$this->backup->pgbackrest_compress_type = $this->pgbackrestCompressType;
$this->backup->pgbackrest_compress_level = $this->pgbackrestCompressLevel;
$this->backup->pgbackrest_log_level = $this->pgbackrestLogLevel;
$this->backup->pgbackrest_archive_mode = $this->pgbackrestArchiveMode;
$this->customValidate();
$this->backup->save();
$this->syncPgbackrestRepos();
$this->customValidate();
$this->backup->save();
$this->syncPgbackrestRepos();
});
} else {
$this->backup->save_s3 = $this->saveS3;
$this->backup->disable_local_backup = $this->disableLocalBackup;