fix: same time backups run multiple times (#134)

This commit is contained in:
Nico 2025-12-13 23:47:41 +01:00 committed by Nicolas Meienberger
parent 3efff035c5
commit 54d077bf43
2 changed files with 3 additions and 5 deletions

View file

@ -17,11 +17,9 @@ export class BackupExecutionJob extends Job {
logger.info(`Found ${scheduleIds.length} backup schedule(s) to execute`);
for (const scheduleId of scheduleIds) {
try {
await backupsService.executeBackup(scheduleId);
} catch (error) {
backupsService.executeBackup(scheduleId).catch((error) => {
logger.error(`Failed to execute backup for schedule ${scheduleId}: ${toMessage(error)}`);
}
});
}
return { done: true, timestamp: new Date(), executed: scheduleIds.length };

View file

@ -370,7 +370,7 @@ const executeBackup = async (scheduleId: number, manual = false) => {
const getSchedulesToExecute = async () => {
const now = Date.now();
const schedules = await db.query.backupSchedulesTable.findMany({
where: eq(backupSchedulesTable.enabled, true),
where: and(eq(backupSchedulesTable.enabled, true), ne(backupSchedulesTable.lastBackupStatus, "in_progress")),
});
const schedulesToRun: number[] = [];