fix(backup): updating new settings correctly in the db
This commit is contained in:
parent
b1cd1a4220
commit
0476dcebb8
8 changed files with 19 additions and 8 deletions
|
|
@ -2712,6 +2712,8 @@ export type CreateBackupScheduleData = {
|
||||||
oneFileSystem?: boolean;
|
oneFileSystem?: boolean;
|
||||||
tags?: Array<string>;
|
tags?: Array<string>;
|
||||||
customResticParams?: Array<string>;
|
customResticParams?: Array<string>;
|
||||||
|
maxRetries?: number;
|
||||||
|
retryDelay?: number;
|
||||||
};
|
};
|
||||||
path?: never;
|
path?: never;
|
||||||
query?: never;
|
query?: never;
|
||||||
|
|
@ -3091,6 +3093,8 @@ export type UpdateBackupScheduleData = {
|
||||||
oneFileSystem?: boolean;
|
oneFileSystem?: boolean;
|
||||||
tags?: Array<string>;
|
tags?: Array<string>;
|
||||||
customResticParams?: Array<string>;
|
customResticParams?: Array<string>;
|
||||||
|
maxRetries?: number;
|
||||||
|
retryDelay?: number;
|
||||||
};
|
};
|
||||||
path: {
|
path: {
|
||||||
shortId: string;
|
shortId: string;
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ export const AdvancedSection = ({ form }: AdvancedSectionProps) => {
|
||||||
onChange={(e) => field.onChange(e.target.value ? Number(e.target.value) : undefined)}
|
onChange={(e) => field.onChange(e.target.value ? Number(e.target.value) : undefined)}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormDescription>Maximum number of retry attempts if a backup fails (default: 0).</FormDescription>
|
<FormDescription>Maximum number of retry attempts if a backup fails (default: 3).</FormDescription>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
|
|
@ -43,7 +43,7 @@ export const AdvancedSection = ({ form }: AdvancedSectionProps) => {
|
||||||
<Input
|
<Input
|
||||||
{...field}
|
{...field}
|
||||||
type="number"
|
type="number"
|
||||||
min={0}
|
min={1}
|
||||||
max={1440}
|
max={1440}
|
||||||
step={1}
|
step={1}
|
||||||
placeholder="e.g., 60"
|
placeholder="e.g., 60"
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ export const CreateScheduleForm = ({ initialValues, formId, onSubmit, volume }:
|
||||||
excludeIfPresent,
|
excludeIfPresent,
|
||||||
customResticParams,
|
customResticParams,
|
||||||
maxRetries,
|
maxRetries,
|
||||||
retryDelay: retryDelay ? retryDelay * 60 * 1000 : 3600000,
|
retryDelay,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[onSubmit],
|
[onSubmit],
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,4 @@ export type BackupScheduleFormValues = Omit<
|
||||||
excludeIfPresent?: string[];
|
excludeIfPresent?: string[];
|
||||||
includePatterns?: string[];
|
includePatterns?: string[];
|
||||||
customResticParams?: string[];
|
customResticParams?: string[];
|
||||||
maxRetries?: number;
|
|
||||||
retryDelay?: number;
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ export const backupScheduleToFormValues = (schedule?: BackupSchedule): InternalF
|
||||||
excludeIfPresentText: schedule.excludeIfPresent?.join("\n") || undefined,
|
excludeIfPresentText: schedule.excludeIfPresent?.join("\n") || undefined,
|
||||||
oneFileSystem: schedule.oneFileSystem ?? false,
|
oneFileSystem: schedule.oneFileSystem ?? false,
|
||||||
customResticParamsText: schedule.customResticParams?.join("\n") ?? "",
|
customResticParamsText: schedule.customResticParams?.join("\n") ?? "",
|
||||||
maxRetries: schedule.maxRetries ?? 5,
|
maxRetries: schedule.maxRetries,
|
||||||
retryDelay: schedule.retryDelay ? schedule.retryDelay / (60 * 60 * 1000) : 1, // Convert ms to hours
|
retryDelay: schedule.retryDelay ? schedule.retryDelay / (60 * 1000) : undefined, // Convert ms to minutes
|
||||||
...cronValues,
|
...cronValues,
|
||||||
...schedule.retentionPolicy,
|
...schedule.retentionPolicy,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,8 @@ export function CreateBackupPage() {
|
||||||
excludeIfPresent: formValues.excludeIfPresent,
|
excludeIfPresent: formValues.excludeIfPresent,
|
||||||
oneFileSystem: formValues.oneFileSystem,
|
oneFileSystem: formValues.oneFileSystem,
|
||||||
customResticParams: formValues.customResticParams,
|
customResticParams: formValues.customResticParams,
|
||||||
|
maxRetries: formValues.maxRetries,
|
||||||
|
retryDelay: formValues.retryDelay,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,8 @@ export const createBackupScheduleBody = z.object({
|
||||||
oneFileSystem: z.boolean().optional(),
|
oneFileSystem: z.boolean().optional(),
|
||||||
tags: z.array(z.string()).optional(),
|
tags: z.array(z.string()).optional(),
|
||||||
customResticParams: z.array(z.string()).optional(),
|
customResticParams: z.array(z.string()).optional(),
|
||||||
|
maxRetries: z.number().optional(),
|
||||||
|
retryDelay: z.number().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type CreateBackupScheduleBody = z.infer<typeof createBackupScheduleBody>;
|
export type CreateBackupScheduleBody = z.infer<typeof createBackupScheduleBody>;
|
||||||
|
|
@ -167,6 +169,8 @@ export const updateBackupScheduleBody = z.object({
|
||||||
oneFileSystem: z.boolean().optional(),
|
oneFileSystem: z.boolean().optional(),
|
||||||
tags: z.array(z.string()).optional(),
|
tags: z.array(z.string()).optional(),
|
||||||
customResticParams: z.array(z.string()).optional(),
|
customResticParams: z.array(z.string()).optional(),
|
||||||
|
maxRetries: z.number().optional(),
|
||||||
|
retryDelay: z.number().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type UpdateBackupScheduleBody = z.infer<typeof updateBackupScheduleBody>;
|
export type UpdateBackupScheduleBody = z.infer<typeof updateBackupScheduleBody>;
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,8 @@ const createSchedule = async (data: CreateBackupScheduleBody) => {
|
||||||
customResticParams: data.customResticParams ?? [],
|
customResticParams: data.customResticParams ?? [],
|
||||||
nextBackupAt: nextBackupAt,
|
nextBackupAt: nextBackupAt,
|
||||||
shortId: generateShortId(),
|
shortId: generateShortId(),
|
||||||
|
maxRetries: data.maxRetries,
|
||||||
|
retryDelay: data.retryDelay ? data.retryDelay * 60 * 1000 : undefined,
|
||||||
organizationId,
|
organizationId,
|
||||||
})
|
})
|
||||||
.returning();
|
.returning();
|
||||||
|
|
@ -163,10 +165,11 @@ const updateSchedule = async (scheduleIdOrShortId: number | string, data: Update
|
||||||
const cronExpression = data.cronExpression ?? schedule.cronExpression;
|
const cronExpression = data.cronExpression ?? schedule.cronExpression;
|
||||||
const nextBackupAt =
|
const nextBackupAt =
|
||||||
data.cronExpression === "" ? null : data.cronExpression ? calculateNextRun(cronExpression) : schedule.nextBackupAt;
|
data.cronExpression === "" ? null : data.cronExpression ? calculateNextRun(cronExpression) : schedule.nextBackupAt;
|
||||||
|
const retryDelay = data.retryDelay ? data.retryDelay * 60 * 1000 : schedule.retryDelay;
|
||||||
|
|
||||||
const [updated] = await db
|
const [updated] = await db
|
||||||
.update(backupSchedulesTable)
|
.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)))
|
.where(and(eq(backupSchedulesTable.id, schedule.id), eq(backupSchedulesTable.organizationId, organizationId)))
|
||||||
.returning();
|
.returning();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue