Files
coolify/resources/views/livewire/project/database/backup-edit/general.blade.php
T
Andras Bacsai 50be16be8f revert(scheduler): go back to the cron scan and keep the reliability fixes
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.
2026-10-02 08:05:18 +02:00

102 lines
6.2 KiB
PHP

<form wire:submit="submit">
<x-unsaved-bar action="submit" />
<x-application.settings-section title="Backup schedule"
description="Choose what to back up, when it runs, and how long it may run.">
<x-slot:actions>
<div class="flex items-center gap-2">
@if (! $backupEnabled)
<x-forms.button type="button" wire:click="toggleEnabled" wire:loading.attr="disabled"
wire:target="toggleEnabled" isHighlighted>
Enable backup
</x-forms.button>
@else
<x-forms.button type="button" wire:click="toggleEnabled" wire:loading.attr="disabled"
wire:target="toggleEnabled">
Disable backup
</x-forms.button>
@endif
<x-forms.button type="button" wire:click="backupNow"
:disabled="! str($status)->startsWith('running')"
:tooltip="! str($status)->startsWith('running') ? 'The database must be running to start a backup.' : null">Back up now</x-forms.button>
</div>
</x-slot:actions>
<div class="space-y-5">
@if ($backup->database_type === 'App\Models\StandalonePostgresql' && $backup->database_id !== 0
|| $backup->database_type === 'App\Models\StandaloneMysql'
|| $backup->database_type === 'App\Models\StandaloneMariadb')
<div class="grid w-full gap-4">
<x-forms.listbox id="dumpAll" label="Database selection" onChange="instantSave" :options="[
['value' => true, 'label' => 'All databases'],
['value' => false, 'label' => 'Specific databases'],
]" />
@if (! $backup->dump_all)
<div class="w-full" x-data="{
value: @entangle('databasesToBackup').live,
draft: '',
get databases() {
return (this.value || '').split(',').map(name => name.trim()).filter(Boolean);
},
addDatabase() {
const names = this.draft.split(',').map(name => name.trim()).filter(Boolean);
if (names.length === 0) return;
this.value = [...new Set([...this.databases, ...names])].join(',');
this.draft = '';
},
removeDatabase(index) {
this.value = this.databases.filter((_, itemIndex) => itemIndex !== index).join(',');
},
}">
<label class="mb-1.5 block text-sm font-medium">Databases to back up</label>
<div class="chip-input">
<template x-for="(database, index) in databases" :key="database">
<span class="chip font-mono">
<span x-text="database"></span>
<button type="button" @click="removeDatabase(index)"
class="chip-remove"
:aria-label="`Remove ${database}`">
<x-reicon name="x" class="size-3" />
</button>
</span>
</template>
<input x-model="draft" @keydown.enter.prevent="addDatabase()"
@keydown="if ($event.key === ',') { $event.preventDefault(); addDatabase(); }"
@blur="addDatabase()" type="text"
placeholder="Type a database and press Enter" />
</div>
<p class="mt-1.5 text-xs text-neutral-500 dark:text-fg-dim">
Add one or more database names. Leave empty to include the default database.
</p>
</div>
@endif
</div>
@elseif ($backup->database_type === 'App\Models\StandaloneMongodb')
<x-forms.input label="Databases to include"
helper="Use database:collection1,collection2|database2 to exclude selected collections. Leave empty to include all databases and collections."
id="databasesToBackup" />
@elseif ($backup->database_type === 'App\Models\StandaloneClickhouse')
<x-forms.input label="Databases to back up"
helper="Comma-separated database names. Leave empty to include the default database."
id="databasesToBackup" />
@elseif ($backup->database_type === 'App\Models\StandaloneSqlite')
<x-forms.input label="Database files to back up"
helper="Comma-separated file names inside the data volume. Leave empty to back up every configured file."
id="databasesToBackup" />
@endif
<div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
<x-forms.input label="Frequency" id="frequency" required />
<x-forms.input label="Timezone" id="timezone" disabled
helper="Uses the deployment server timezone, or the instance timezone when none is configured."
required />
<x-forms.input label="Timeout" id="timeout" type="number" min="60"
helper="Maximum backup runtime in seconds." required />
<x-forms.input label="Missing backup alert after" id="missingBackupNotificationDays" type="number"
min="0" max="365" suffix="days" canGate="manageBackups" :canResource="$backup->database"
helper="Notify through backup failure channels after this many days without an execution. Use 0 to disable." required />
</div>
</div>
</x-application.settings-section>
</form>