fix: same time backups run multiple times (#134)
This commit is contained in:
parent
6ab5c549c1
commit
be53466739
2 changed files with 3 additions and 5 deletions
|
|
@ -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 };
|
||||
|
|
|
|||
|
|
@ -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[] = [];
|
||||
|
|
|
|||
Loading…
Reference in a new issue