diff --git a/app/client/api-client/types.gen.ts b/app/client/api-client/types.gen.ts index 6b92a662..3d7be795 100644 --- a/app/client/api-client/types.gen.ts +++ b/app/client/api-client/types.gen.ts @@ -2712,6 +2712,8 @@ export type CreateBackupScheduleData = { oneFileSystem?: boolean; tags?: Array; customResticParams?: Array; + maxRetries?: number; + retryDelay?: number; }; path?: never; query?: never; @@ -3091,6 +3093,8 @@ export type UpdateBackupScheduleData = { oneFileSystem?: boolean; tags?: Array; customResticParams?: Array; + maxRetries?: number; + retryDelay?: number; }; path: { shortId: string; diff --git a/app/client/modules/backups/components/create-schedule-form/advanced-section.tsx b/app/client/modules/backups/components/create-schedule-form/advanced-section.tsx index a383e1f1..a7282ab6 100644 --- a/app/client/modules/backups/components/create-schedule-form/advanced-section.tsx +++ b/app/client/modules/backups/components/create-schedule-form/advanced-section.tsx @@ -28,7 +28,7 @@ export const AdvancedSection = ({ form }: AdvancedSectionProps) => { onChange={(e) => field.onChange(e.target.value ? Number(e.target.value) : undefined)} /> - Maximum number of retry attempts if a backup fails (default: 0). + Maximum number of retry attempts if a backup fails (default: 3). )} @@ -43,7 +43,7 @@ export const AdvancedSection = ({ form }: AdvancedSectionProps) => { ; @@ -167,6 +169,8 @@ export const updateBackupScheduleBody = z.object({ oneFileSystem: z.boolean().optional(), tags: z.array(z.string()).optional(), customResticParams: z.array(z.string()).optional(), + maxRetries: z.number().optional(), + retryDelay: z.number().optional(), }); export type UpdateBackupScheduleBody = z.infer; diff --git a/app/server/modules/backups/backups.service.ts b/app/server/modules/backups/backups.service.ts index 3b9ff793..99cc574c 100644 --- a/app/server/modules/backups/backups.service.ts +++ b/app/server/modules/backups/backups.service.ts @@ -111,6 +111,8 @@ const createSchedule = async (data: CreateBackupScheduleBody) => { customResticParams: data.customResticParams ?? [], nextBackupAt: nextBackupAt, shortId: generateShortId(), + maxRetries: data.maxRetries, + retryDelay: data.retryDelay ? data.retryDelay * 60 * 1000 : undefined, organizationId, }) .returning(); @@ -163,10 +165,11 @@ const updateSchedule = async (scheduleIdOrShortId: number | string, data: Update const cronExpression = data.cronExpression ?? schedule.cronExpression; const nextBackupAt = data.cronExpression === "" ? null : data.cronExpression ? calculateNextRun(cronExpression) : schedule.nextBackupAt; + const retryDelay = data.retryDelay ? data.retryDelay * 60 * 1000 : schedule.retryDelay; const [updated] = await db .update(backupSchedulesTable) - .set({ ...data, repositoryId: repository.id, nextBackupAt, updatedAt: Date.now() }) + .set({ ...data, repositoryId: repository.id, nextBackupAt, updatedAt: Date.now(), retryDelay }) .where(and(eq(backupSchedulesTable.id, schedule.id), eq(backupSchedulesTable.organizationId, organizationId))) .returning();