mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 22:46:16 +00:00
database backups
This commit is contained in:
@ -0,0 +1,74 @@
|
||||
<div x-data="">
|
||||
<x-card-header>
|
||||
<x-slot name="title">{{ __("Backup Files") }}</x-slot>
|
||||
<x-slot name="description">{{ __("Here you can see your backup files") }}</x-slot>
|
||||
<x-slot name="aside">
|
||||
<div>
|
||||
<x-secondary-button :href="route('servers.databases', ['server' => $server])">
|
||||
{{ __('Back to Databases') }}
|
||||
</x-secondary-button>
|
||||
<x-primary-button class="ml-1" wire:click="backup" wire:loading.attr="disabled">
|
||||
{{ __("Backup Now") }}
|
||||
</x-primary-button>
|
||||
</div>
|
||||
</x-slot>
|
||||
</x-card-header>
|
||||
@if(count($files) > 0)
|
||||
<x-table class="mt-5">
|
||||
<tr>
|
||||
<x-th>{{ __("Name") }}</x-th>
|
||||
<x-th>{{ __("Created") }}</x-th>
|
||||
<x-th>{{ __("Size") }}</x-th>
|
||||
<x-th>{{ __("Status") }}</x-th>
|
||||
<x-th>{{ __("Restored") }}</x-th>
|
||||
<x-th>{{ __("Restored To") }}</x-th>
|
||||
<x-th></x-th>
|
||||
</tr>
|
||||
@foreach($files as $file)
|
||||
<tr>
|
||||
<x-td>{{ $file->name }}</x-td>
|
||||
<x-td>
|
||||
<x-datetime :value="$file->created_at" />
|
||||
</x-td>
|
||||
<x-td>{{ $file->size }}</x-td>
|
||||
<x-td>
|
||||
<div class="inline-flex">
|
||||
@include('livewire.databases.partials.backup-file-status', ['status' => $file->status])
|
||||
</div>
|
||||
</x-td>
|
||||
<x-td>
|
||||
@if($file->restored_at)
|
||||
<x-datetime :value="$file->restored_at" />
|
||||
@else
|
||||
-
|
||||
@endif
|
||||
</x-td>
|
||||
<x-td>
|
||||
@if($file->restored_to)
|
||||
{{ $file->restored_to }}
|
||||
@else
|
||||
-
|
||||
@endif
|
||||
</x-td>
|
||||
<x-td class="flex w-full justify-end">
|
||||
@if(in_array($file->status, [\App\Enums\BackupFileStatus::CREATED, \App\Enums\BackupFileStatus::RESTORED, \App\Enums\BackupFileStatus::RESTORE_FAILED]))
|
||||
<x-icon-button x-on:click="$wire.restoreId = '{{ $file->id }}'; $dispatch('open-modal', 'restore-backup')">
|
||||
Restore
|
||||
</x-icon-button>
|
||||
@endif
|
||||
<x-icon-button x-on:click="$wire.deleteId = '{{ $file->id }}'; $dispatch('open-modal', 'delete-backup-file')">
|
||||
Delete
|
||||
</x-icon-button>
|
||||
</x-td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</x-table>
|
||||
<div class="mt-5">
|
||||
{{ $files->withQueryString()->links() }}
|
||||
</div>
|
||||
@include('livewire.databases.partials.restore-backup-modal', ['databases' => $server->databases])
|
||||
@include('livewire.databases.partials.delete-backup-file-modal')
|
||||
@else
|
||||
<x-simple-card class="text-center">{{ __("You don't have any backups yet") }}</x-simple-card>
|
||||
@endif
|
||||
</div>
|
@ -0,0 +1,49 @@
|
||||
<div x-data="">
|
||||
<x-card-header>
|
||||
<x-slot name="title">{{ __("Backups") }}</x-slot>
|
||||
<x-slot name="description">{{ __("You can backup your databases into external storages") }}</x-slot>
|
||||
<x-slot name="aside">
|
||||
<div>
|
||||
<x-primary-button x-data="" x-on:click.prevent="$dispatch('open-modal', 'create-backup')">
|
||||
{{ __('Create Backup') }}
|
||||
</x-primary-button>
|
||||
|
||||
@include('livewire.databases.partials.create-backup-modal')
|
||||
</div>
|
||||
</x-slot>
|
||||
</x-card-header>
|
||||
@if(count($backups) > 0)
|
||||
<x-table>
|
||||
<tr>
|
||||
<x-th>{{ __("Database") }}</x-th>
|
||||
<x-th>{{ __("Created") }}</x-th>
|
||||
<x-th>{{ __("Status") }}</x-th>
|
||||
<x-th></x-th>
|
||||
</tr>
|
||||
@foreach($backups as $backup)
|
||||
<tr>
|
||||
<x-td>{{ $backup->database->name }}</x-td>
|
||||
<x-td>
|
||||
<x-datetime :value="$backup->created_at" />
|
||||
</x-td>
|
||||
<x-td>
|
||||
<div class="inline-flex">
|
||||
@include('livewire.databases.partials.backup-status', ['status' => $backup->status])
|
||||
</div>
|
||||
</x-td>
|
||||
<x-td class="flex w-full justify-end">
|
||||
<x-icon-button :href="route('servers.databases.backups', ['server' => $server->id, 'backup' => $backup->id])">
|
||||
Files
|
||||
</x-icon-button>
|
||||
<x-icon-button x-on:click="$wire.deleteId = '{{ $backup->id }}'; $dispatch('open-modal', 'delete-backup')">
|
||||
Delete
|
||||
</x-icon-button>
|
||||
</x-td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</x-table>
|
||||
@include('livewire.databases.partials.delete-backup-modal')
|
||||
@else
|
||||
<x-simple-card class="text-center">{{ __("You don't have any backups yet") }}</x-simple-card>
|
||||
@endif
|
||||
</div>
|
@ -15,10 +15,10 @@
|
||||
@if(count($databases) > 0)
|
||||
<x-table>
|
||||
<tr>
|
||||
<x-td>{{ __("Name") }}</x-td>
|
||||
<x-td>{{ __("Created") }}</x-td>
|
||||
<x-td>{{ __("Status") }}</x-td>
|
||||
<x-td></x-td>
|
||||
<x-th>{{ __("Name") }}</x-th>
|
||||
<x-th>{{ __("Created") }}</x-th>
|
||||
<x-th>{{ __("Status") }}</x-th>
|
||||
<x-th></x-th>
|
||||
</tr>
|
||||
@foreach($databases as $database)
|
||||
<tr>
|
||||
|
@ -15,11 +15,11 @@
|
||||
@if(count($databaseUsers) > 0)
|
||||
<x-table>
|
||||
<tr>
|
||||
<x-td>{{ __("Username") }}</x-td>
|
||||
<x-td>{{ __("Created") }}</x-td>
|
||||
<x-td>{{ __("Linked Databases") }}</x-td>
|
||||
<x-td>{{ __("Status") }}</x-td>
|
||||
<x-td></x-td>
|
||||
<x-th>{{ __("Username") }}</x-th>
|
||||
<x-th>{{ __("Created") }}</x-th>
|
||||
<x-th>{{ __("Linked Databases") }}</x-th>
|
||||
<x-th>{{ __("Status") }}</x-th>
|
||||
<x-th></x-th>
|
||||
</tr>
|
||||
@foreach($databaseUsers as $databaseUser)
|
||||
<tr>
|
||||
|
@ -0,0 +1,21 @@
|
||||
@if($status == \App\Enums\BackupFileStatus::CREATED)
|
||||
<x-status status="success">{{ $status }}</x-status>
|
||||
@endif
|
||||
@if($status == \App\Enums\BackupFileStatus::CREATING)
|
||||
<x-status status="warning">{{ $status }}</x-status>
|
||||
@endif
|
||||
@if($status == \App\Enums\BackupFileStatus::FAILED)
|
||||
<x-status status="danger">{{ $status }}</x-status>
|
||||
@endif
|
||||
@if($status == \App\Enums\BackupFileStatus::DELETING)
|
||||
<x-status status="danger">{{ $status }}</x-status>
|
||||
@endif
|
||||
@if($status == \App\Enums\BackupFileStatus::RESTORING)
|
||||
<x-status status="warning">{{ $status }}</x-status>
|
||||
@endif
|
||||
@if($status == \App\Enums\BackupFileStatus::RESTORED)
|
||||
<x-status status="success">{{ $status }}</x-status>
|
||||
@endif
|
||||
@if($status == \App\Enums\BackupFileStatus::RESTORE_FAILED)
|
||||
<x-status status="danger">{{ $status }}</x-status>
|
||||
@endif
|
@ -0,0 +1,9 @@
|
||||
@if($status == \App\Enums\BackupStatus::RUNNING)
|
||||
<x-status status="success">{{ $status }}</x-status>
|
||||
@endif
|
||||
@if($status == \App\Enums\BackupStatus::DELETING)
|
||||
<x-status status="danger">{{ $status }}</x-status>
|
||||
@endif
|
||||
@if($status == \App\Enums\BackupStatus::FAILED)
|
||||
<x-status status="danger">{{ $status }}</x-status>
|
||||
@endif
|
@ -0,0 +1,78 @@
|
||||
<x-modal name="create-backup">
|
||||
<form wire:submit.prevent="create" class="p-6" x-data="{user: false, remote: false}">
|
||||
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
|
||||
{{ __('Create Backup') }}
|
||||
</h2>
|
||||
|
||||
<div class="mt-6">
|
||||
<x-input-label for="database" :value="__('Database')" />
|
||||
<x-select-input wire:model="database" id="database" name="database" class="mt-1 w-full">
|
||||
<option value="" selected disabled>{{ __("Select") }}</option>
|
||||
@foreach($databases as $db)
|
||||
<option value="{{ $db->id }}" @if($database == $db->id) selected @endif>{{ $db->name }}</option>
|
||||
@endforeach
|
||||
</x-select-input>
|
||||
@error('database')
|
||||
<x-input-error class="mt-2" :messages="$message" />
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="mt-6">
|
||||
<x-input-label for="storage" :value="__('Storage')" />
|
||||
<x-select-input wire:model="storage" id="storage" name="storage" class="mt-1 w-full">
|
||||
<option value="" selected disabled>{{ __("Select") }}</option>
|
||||
@foreach(auth()->user()->storageProviders as $st)
|
||||
<option value="{{ $st->id }}" @if($storage == $st->id) selected @endif>{{ $st->profile }} - {{ $st->provider }}</option>
|
||||
@endforeach
|
||||
</x-select-input>
|
||||
@error('storage')
|
||||
<x-input-error class="mt-2" :messages="$message" />
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
|
||||
<div class="mt-6">
|
||||
<x-input-label for="interval" :value="__('Interval')" />
|
||||
<x-select-input wire:model="interval" id="interval" name="interval" class="mt-1 w-full">
|
||||
<option value="" selected disabled>{{ __("Select") }}</option>
|
||||
<option value="0 * * * *" @if($interval === '0 * * * *') selected @endif>{{ __("Hourly") }}</option>
|
||||
<option value="0 0 * * *" @if($interval === '0 0 * * *') selected @endif>{{ __("Daily") }}</option>
|
||||
<option value="0 0 * * 0" @if($interval === '0 0 * * 0') selected @endif>{{ __("Weekly") }}</option>
|
||||
<option value="0 0 1 * *" @if($interval === '0 0 1 * *') selected @endif>{{ __("Monthly") }}</option>
|
||||
<option value="custom">{{ __("Custom") }}</option>
|
||||
</x-select-input>
|
||||
@error('interval')
|
||||
<x-input-error class="mt-2" :messages="$message" />
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
|
||||
@if($interval === 'custom')
|
||||
<div class="mt-6">
|
||||
<x-input-label for="custom" :value="__('Custom interval (Cron)')" />
|
||||
<x-text-input wire:model.defer="custom" id="custom" name="custom" type="text" class="mt-1 w-full" placeholder="* * * * *" />
|
||||
@error('custom')
|
||||
<x-input-error class="mt-2" :messages="$message" />
|
||||
@enderror
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="mt-6">
|
||||
<x-input-label for="keep" :value="__('Backups to Keep')" />
|
||||
<x-text-input wire:model.defer="keep" id="keep" name="keep" type="text" class="mt-1 w-full" />
|
||||
@error('keep')
|
||||
<x-input-error class="mt-2" :messages="$message" />
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="mt-6 flex justify-end">
|
||||
<x-secondary-button type="button" x-on:click="$dispatch('close')">
|
||||
{{ __('Cancel') }}
|
||||
</x-secondary-button>
|
||||
|
||||
<x-primary-button class="ml-3" @backup-created.window="$dispatch('close')">
|
||||
{{ __('Create') }}
|
||||
</x-primary-button>
|
||||
</div>
|
||||
</form>
|
||||
</x-modal>
|
@ -0,0 +1,6 @@
|
||||
<x-confirm-modal
|
||||
name="delete-backup-file"
|
||||
:title="__('Confirm')"
|
||||
:description="__('Are you sure that you want to delete this file?')"
|
||||
method="delete"
|
||||
/>
|
@ -0,0 +1,6 @@
|
||||
<x-confirm-modal
|
||||
name="delete-backup"
|
||||
:title="__('Confirm')"
|
||||
:description="__('Are you sure that you want to delete this backup?')"
|
||||
method="delete"
|
||||
/>
|
@ -0,0 +1,30 @@
|
||||
<x-modal name="restore-backup">
|
||||
<form wire:submit.prevent="restore" class="p-6" x-data="{}">
|
||||
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
|
||||
{{ __('Restore Backup') }}
|
||||
</h2>
|
||||
|
||||
<div class="mt-6">
|
||||
<x-input-label for="database" :value="__('Database')" />
|
||||
<x-select-input wire:model="restoreDatabaseId" id="restoreDatabaseId" name="restoreDatabaseId" class="mt-1 w-full">
|
||||
<option value="" selected disabled>{{ __("Select") }}</option>
|
||||
@foreach($databases as $db)
|
||||
<option value="{{ $db->id }}" @if($restoreDatabaseId == $db->id) selected @endif>{{ $db->name }}</option>
|
||||
@endforeach
|
||||
</x-select-input>
|
||||
@error('restoreDatabaseId')
|
||||
<x-input-error class="mt-2" :messages="$message" />
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="mt-6 flex justify-end">
|
||||
<x-secondary-button type="button" x-on:click="$dispatch('close')">
|
||||
{{ __('Cancel') }}
|
||||
</x-secondary-button>
|
||||
|
||||
<x-primary-button class="ml-3" @restored.window="$dispatch('close')">
|
||||
{{ __('Restore') }}
|
||||
</x-primary-button>
|
||||
</div>
|
||||
</form>
|
||||
</x-modal>
|
Reference in New Issue
Block a user