fix: automatically put in_progress backups to warning during startup

This commit is contained in:
Nicolas Meienberger 2025-12-21 14:17:28 +01:00
parent 97d0a86946
commit a32e49c4cf
2 changed files with 15 additions and 2 deletions

View file

@ -181,7 +181,8 @@ export const ScheduleSummary = (props: Props) => {
<div className="md:col-span-2 lg:col-span-4">
<p className="text-xs uppercase text-muted-foreground">Warning Details</p>
<p className="font-mono text-sm text-yellow-600 whitespace-pre-wrap break-all">
Last backup completed with warnings. Check your container logs for more details.
{schedule.lastBackupError ??
"Last backup completed with warnings. Check your container logs for more details."}
</p>
</div>
)}

View file

@ -1,7 +1,7 @@
import { Scheduler } from "../../core/scheduler";
import { and, eq, or } from "drizzle-orm";
import { db } from "../../db/db";
import { volumesTable } from "../../db/schema";
import { backupSchedulesTable, volumesTable } from "../../db/schema";
import { logger } from "../../utils/logger";
import { restic } from "../../utils/restic";
import { volumeService } from "../volumes/volume.service";
@ -63,6 +63,18 @@ export const startup = async () => {
});
}
await db
.update(backupSchedulesTable)
.set({
lastBackupStatus: "warning",
lastBackupError: "Zerobyte was restarted during the last scheduled backup",
updatedAt: Date.now(),
})
.where(eq(backupSchedulesTable.lastBackupStatus, "in_progress"))
.catch((err) => {
logger.error(`Failed to update stuck backup schedules on startup: ${err.message}`);
});
Scheduler.build(CleanupDanglingMountsJob).schedule("0 * * * *");
Scheduler.build(VolumeHealthCheckJob).schedule("*/30 * * * *");
Scheduler.build(RepositoryHealthCheckJob).schedule("50 12 * * *");