@extends('layouts.user_type.auth') @section('backupLog')
@include('components.alert') @php $ls = $summary['last_success']; $last = $summary['last']; @endphp {{-- stale / failure banner --}} @if($summary['stale'])
@if($ls) No successful database backup for {{ $ls->ran_at->diffForHumans(null, true) }} (expected every {{ $summary['stale_hours'] }} h). Check the crontab on the backup server. @else No successful database backup has been recorded yet. Add the backup:log call to your crontab backup script (see “How to connect” below). @endif
@elseif($last && $last->status === 'failed')
The latest backup run failed {{ $last->ran_at->diffForHumans() }}: {{ \Illuminate\Support\Str::limit($last->message, 140) }}
@endif {{-- summary --}}
{{ $summary['stale'] ? 'Stale' : 'Healthy' }}
{{ $ls ? $ls->ran_at->diffForHumans() : 'Never' }}
Last successful backup
@if($ls)
{{ $ls->ran_at->format('d M Y, H:i') }}
@endif
@if($last){{ ucfirst($last->status) }}@endif
{{ $summary['latest_size'] }}
Latest backup size
@if($ls && $ls->storage_path)
{{ $ls->storage_path }}
@endif
30 days
{{ $summary['success_rate'] !== null ? $summary['success_rate'].'%' : '—' }}
Success rate
30 days
{{ $summary['runs_30'] }}
Runs · {{ $summary['failed_30'] }} failed
{{-- history --}}
Backup History

Every database backup run reported by the crontab script.

{{ $logs->total() }} Records
@forelse($logs as $i => $log) @empty @endforelse
# Backup Status File Size Duration Server Finished
{{ str_pad($logs->firstItem() + $i, 2, '0', STR_PAD_LEFT) }}
{{ $log->backup_name }}
{{ $log->database_name ?: 'Database' }} · {{ ucfirst($log->source) }}
{{ ucfirst($log->status) }}
{{ $log->file_name ?: '—' }}
@if($log->status === 'failed' && $log->message)
{{ $log->message }}
@elseif($log->storage_path)
{{ $log->storage_path }}
@endif
{{ $log->size_for_humans }} {{ $log->duration_seconds !== null ? gmdate($log->duration_seconds >= 3600 ? 'H:i:s' : 'i:s', (int) $log->duration_seconds) : '—' }} {{ $log->host ?: '—' }} {{ $log->ran_at->format('d-m-Y') }}
{{ $log->ran_at->format('H:i:s') }}

No backups recorded yet

@include('components.pagination', ['paginator' => $logs])
{{-- how to connect the crontab --}}
How to connect your crontab backup

Add one line after the dump/upload in the backup script on Google Cloud.

Same server as this app — run the artisan command:

php {{ base_path('artisan') }} backup:log success --name=mysql-daily --database=all \
    --file="$FILE" --size="$(stat -c%s "$LOCAL_FILE")" --path="gs://YOUR_BUCKET/$FILE" --duration="$SECONDS"

# on failure (e.g. in the script's error trap)
php {{ base_path('artisan') }} backup:log failed --name=mysql-daily --message="mysqldump failed"

Different server — call the API (set BACKUP_LOG_TOKEN in .env first):

curl -fsS -X POST {{ url('/api/backup-log') }} \
  -H "X-Backup-Token: $BACKUP_LOG_TOKEN" -H "Accept: application/json" \
  -d status=success -d backup_name=mysql-daily -d file_name="$FILE" \
  -d file_size="$(stat -c%s "$LOCAL_FILE")" -d storage_path="gs://YOUR_BUCKET/$FILE"
@endsection