Application backups were driven by one crontab entry per app, each offset by id * CFG_BACKUP_CRONTAB_APP_INTERVAL minutes. That minute offset is written straight into cron's 0-59 minute field, so past ~20 apps it overflowed into an invalid entry that silently never fired, and the fixed spacing could not serialize backups that ran longer than the gap. Replace it with a single daily entry (`libreportal backup scheduled`) that enqueues a backup task per enabled app. The existing systemd task processor drains them serially — no minute overflow, real serialization, and backups are now visible/cancellable in the Tasks UI. Per-app enable is read from CFG_<APP>_BACKUP at schedule time instead of being mirrored into crontab. Removes the stagger machinery (timing/setup/check/remove scripts), the now-unused cron_jobs table + insert, and the CFG_BACKUP_CRONTAB_APP_INTERVAL config knob and its WebUI field. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: librelad <librelad@digitalangels.vip>
32 lines
1.4 KiB
Bash
32 lines
1.4 KiB
Bash
#!/bin/bash
|
|
|
|
# Install (or refresh) the single daily crontab entry that drives application
|
|
# backups. The entry runs `libreportal backup scheduled`, which enqueues a
|
|
# backup task per enabled app for the processor to drain serially.
|
|
crontabSetupBackupScheduler()
|
|
{
|
|
local ISCRON=$( (sudo -u $sudo_user_name crontab -l) 2>/dev/null )
|
|
|
|
if [[ "$ISCRON" == *"command not found"* ]]; then
|
|
isNotice "Crontab is not found. Unable to set up the backup scheduler."
|
|
return 0
|
|
fi
|
|
|
|
if ! sudo -u $sudo_user_name crontab -l 2>/dev/null | grep -q "cron is set up for $sudo_user_name"; then
|
|
isNotice "Crontab is not set up, skipping backup scheduler until it's found."
|
|
return 0
|
|
fi
|
|
|
|
local marker="# CRONTAB BACKUP SCHEDULER"
|
|
local scheduler_entry="$CFG_BACKUP_CRONTAB_APP libreportal backup scheduled $marker"
|
|
|
|
# Drop any previous scheduler entry, then re-add the current one so a
|
|
# changed schedule (CFG_BACKUP_CRONTAB_APP) always takes effect.
|
|
local result=$(sudo -u $sudo_user_name crontab -l 2>/dev/null | grep -v "$marker" | sudo -u $sudo_user_name crontab -)
|
|
local result=$( (sudo -u $sudo_user_name crontab -l 2>/dev/null; echo "$scheduler_entry") | sudo -u $sudo_user_name crontab - )
|
|
checkSuccess "Installing the daily backup scheduler entry"
|
|
|
|
local schedule_time=$(echo "$CFG_BACKUP_CRONTAB_APP" | cut -d' ' -f2)
|
|
isSuccessful "Enabled apps will be queued for backup daily at ${schedule_time}:00"
|
|
}
|