mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-16 09:42:29 -04:00
The missed daily backups on Coolify Cloud came from Redis evicting queue keys (allkeys-lfu on a full instance), not from the scan of all schedules. The next_run_at design (452259aac,5c5740533) did not prevent that, and it added stored state that must be kept in sync on every frequency, timezone, and server change. It was not released, so remove it: - revert next_run_at, its model hooks, the "Next run" UI, and the diagnostics changes; restore scheduled_job_states and the queue overlap lock - a new migration removes the next_run_at columns and creates scheduled_job_states again where the removed migration already ran Keep the changes that fix real problems: - run the manager every minute from the scheduler with `scheduled:dispatch`, so a busy queue cannot delay it past the catch-up window - load the server chain of scheduled backups with each chunk, which removes about 7,000 queries per run on Coolify Cloud - catch Throwable for each schedule, so one broken schedule does not stop the others - publish database and volume backups again when their queued job was not started after 60 minutes (for example, lost in Redis); log lost tasks and Docker cleanups as missed. A lost backup is not run again when a newer occurrence of the same schedule exists.
118 lines
7.5 KiB
PHP
118 lines
7.5 KiB
PHP
<div>
|
||
<x-slot:title>
|
||
{{ data_get_str($server, 'name')->limit(10) }} > Docker Cleanup | Coolify
|
||
</x-slot>
|
||
|
||
<livewire:server.navbar :server="$server" />
|
||
|
||
<div
|
||
class="server-settings-workspace application-settings-workspace mt-4 grid w-full max-w-none min-w-0 gap-8 lg:mt-0 xl:grid-cols-[210px_minmax(0,1fr)] xl:gap-8">
|
||
<x-server.sidebar :server="$server" activeMenu="docker-cleanup" />
|
||
|
||
<div class="application-settings-form flex w-full flex-col gap-6">
|
||
<form wire:submit="submit" class="contents">
|
||
{{-- Scope to cron/threshold fields; listboxes use instantSave and would flash the bar. --}}
|
||
<x-unsaved-bar action="submit"
|
||
targets="dockerCleanupFrequency,dockerCleanupThreshold" />
|
||
|
||
<x-application.settings-section id="docker-cleanup-overview-section" title="Docker cleanup"
|
||
helper="Remove unused Docker data and keep disk usage under control.">
|
||
<x-slot:actions>
|
||
@can('update', $server)
|
||
<x-modal-confirmation title="Confirm Docker Cleanup?"
|
||
buttonTitle="Run cleanup" isHighlightedButton submitAction="manualCleanup"
|
||
:actions="[
|
||
'Deletes stopped containers managed by Coolify.',
|
||
'Deletes unused images and clears the build cache.',
|
||
'Removes old Coolify helper images.',
|
||
'May delete unused volumes or networks when those options are enabled.',
|
||
]" :confirmWithText="false" :confirmWithPassword="false"
|
||
step2ButtonText="Run Docker Cleanup" />
|
||
@endcan
|
||
</x-slot:actions>
|
||
|
||
@if (!isCloud() && $this->isCleanupStale)
|
||
<x-callout type="warning" title="Docker cleanup may be stalled">
|
||
The last cleanup ran {{ $this->lastExecutionTime ?? 'at an unknown time' }}.
|
||
@if (!$this->isSchedulerHealthy)
|
||
The scheduled job manager also appears inactive.
|
||
@endif
|
||
Run
|
||
<code class="rounded bg-black/10 px-1 dark:bg-white/10">php artisan cleanup:redis --clear-locks</code>
|
||
on the Coolify instance to clear stale locks.
|
||
</x-callout>
|
||
@else
|
||
<div class="flex items-start gap-3">
|
||
<div
|
||
class="flex size-9 shrink-0 items-center justify-center rounded-lg bg-neutral-100 text-neutral-500 dark:bg-white/[0.06] dark:text-fg-dim">
|
||
<x-reicon name="storages" class="size-4" />
|
||
</div>
|
||
<div>
|
||
<p class="text-sm font-medium text-neutral-950 dark:text-fg">Scheduled maintenance</p>
|
||
<p class="mt-1 text-xs leading-5 text-neutral-500 dark:text-fg-dim">
|
||
Cleanup runs automatically using the schedule and threshold configured below.
|
||
</p>
|
||
</div>
|
||
</div>
|
||
@endif
|
||
</x-application.settings-section>
|
||
|
||
<x-application.settings-section id="docker-cleanup-configuration-section"
|
||
title="Cleanup configuration"
|
||
helper="Choose when cleanup runs and whether it should wait for a disk threshold.">
|
||
<div class="grid gap-4 lg:grid-cols-2">
|
||
<x-forms.input canGate="update" :canResource="$server" placeholder="0 0 * * *"
|
||
id="dockerCleanupFrequency" label="Cleanup frequency" required
|
||
helper="Cron expression or preset such as hourly, daily, weekly, monthly, or yearly." />
|
||
@if (!$forceDockerCleanup)
|
||
<x-forms.input canGate="update" :canResource="$server" id="dockerCleanupThreshold"
|
||
type="number" min="1" max="99" label="Disk threshold" required
|
||
helper="Run cleanup after disk usage exceeds this percentage." />
|
||
@endif
|
||
<x-forms.listbox id="forceDockerCleanup" label="Cleanup trigger"
|
||
helper="Forced cleanup runs on every schedule without waiting for the threshold."
|
||
onChange="instantSave" :options="[
|
||
['value' => false, 'label' => 'Only above disk threshold'],
|
||
['value' => true, 'label' => 'Run on every schedule'],
|
||
]" />
|
||
</div>
|
||
</x-application.settings-section>
|
||
|
||
<x-application.settings-section id="docker-cleanup-advanced-section" title="Advanced cleanup"
|
||
helper="Control destructive cleanup behavior and application image retention.">
|
||
<x-callout type="warning" title="These options can remove recoverable data">
|
||
Unused volumes may contain data from stopped containers, while removing retained images
|
||
disables rollback to older application versions.
|
||
</x-callout>
|
||
|
||
<div class="mt-4 grid gap-4 lg:grid-cols-3">
|
||
<x-forms.listbox id="deleteUnusedVolumes" label="Unused volumes"
|
||
helper="Permanently remove volumes not attached to running containers."
|
||
onChange="instantSave" :options="[
|
||
['value' => false, 'label' => 'Keep unused volumes'],
|
||
['value' => true, 'label' => 'Delete unused volumes'],
|
||
]" />
|
||
<x-forms.listbox id="deleteUnusedNetworks" label="Unused networks"
|
||
helper="Remove Docker networks not attached to running containers."
|
||
onChange="instantSave" :options="[
|
||
['value' => false, 'label' => 'Keep unused networks'],
|
||
['value' => true, 'label' => 'Delete unused networks'],
|
||
]" />
|
||
<x-forms.listbox id="disableApplicationImageRetention" label="Application images"
|
||
helper="Choose Keep retained images to follow each application’s Images to keep setting under Rollback. Delete all old images ignores that setting and keeps only the running image."
|
||
onChange="instantSave" :options="[
|
||
['value' => false, 'label' => 'Keep retained images'],
|
||
['value' => true, 'label' => 'Delete all old images'],
|
||
]" />
|
||
</div>
|
||
</x-application.settings-section>
|
||
</form>
|
||
|
||
<x-application.settings-section id="docker-cleanup-executions-section" title="Recent executions"
|
||
helper="Review cleanup status, duration, and command output." flush>
|
||
<livewire:server.docker-cleanup-executions :server="$server" />
|
||
</x-application.settings-section>
|
||
</div>
|
||
</div>
|
||
</div>
|