This commit is contained in:
Saeed Vaziry
2024-03-24 09:56:34 +01:00
committed by GitHub
parent 884f18db63
commit 4d051330d6
1055 changed files with 14493 additions and 20278 deletions

View File

@ -24,15 +24,15 @@ public function create($type, Server $server, array $input): Backup
$backup = new Backup([
'type' => $type,
'server_id' => $server->id,
'database_id' => $input['database'] ?? null,
'storage_id' => $input['storage'],
'interval' => $input['interval'] == 'custom' ? $input['custom'] : $input['interval'],
'keep_backups' => $input['keep'],
'database_id' => $input['backup_database'] ?? null,
'storage_id' => $input['backup_storage'],
'interval' => $input['backup_interval'] == 'custom' ? $input['backup_custom'] : $input['backup_interval'],
'keep_backups' => $input['backup_keep'],
'status' => BackupStatus::RUNNING,
]);
$backup->save();
$backup->run();
app(RunBackup::class)->run($backup);
return $backup;
}
@ -43,16 +43,16 @@ public function create($type, Server $server, array $input): Backup
private function validate($type, Server $server, array $input): void
{
$rules = [
'storage' => [
'backup_storage' => [
'required',
Rule::exists('storage_providers', 'id'),
],
'keep' => [
'backup_keep' => [
'required',
'numeric',
'min:1',
],
'interval' => [
'backup_interval' => [
'required',
Rule::in([
'0 * * * *',
@ -63,13 +63,13 @@ private function validate($type, Server $server, array $input): void
]),
],
];
if ($input['interval'] == 'custom') {
$rules['custom'] = [
if ($input['backup_interval'] == 'custom') {
$rules['backup_custom'] = [
'required',
];
}
if ($type === 'database') {
$rules['database'] = [
$rules['backup_database'] = [
'required',
Rule::exists('databases', 'id')
->where('server_id', $server->id)