mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
refactor(backups): tag snapshots by backup id and run forget by grouping first by tags
This commit is contained in:
@@ -32,7 +32,6 @@ import {
|
||||
getBackupSchedule,
|
||||
updateBackupSchedule,
|
||||
getBackupScheduleForVolume,
|
||||
upsertBackupSchedule,
|
||||
runBackupNow,
|
||||
} from "../sdk.gen";
|
||||
import { queryOptions, type UseMutationOptions, type DefaultError } from "@tanstack/react-query";
|
||||
@@ -83,8 +82,6 @@ import type {
|
||||
UpdateBackupScheduleData,
|
||||
UpdateBackupScheduleResponse,
|
||||
GetBackupScheduleForVolumeData,
|
||||
UpsertBackupScheduleData,
|
||||
UpsertBackupScheduleResponse,
|
||||
RunBackupNowData,
|
||||
RunBackupNowResponse,
|
||||
} from "../types.gen";
|
||||
@@ -957,29 +954,6 @@ export const getBackupScheduleForVolumeOptions = (options: Options<GetBackupSche
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Create or update a backup schedule for a volume
|
||||
*/
|
||||
export const upsertBackupScheduleMutation = (
|
||||
options?: Partial<Options<UpsertBackupScheduleData>>,
|
||||
): UseMutationOptions<UpsertBackupScheduleResponse, DefaultError, Options<UpsertBackupScheduleData>> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
UpsertBackupScheduleResponse,
|
||||
DefaultError,
|
||||
Options<UpsertBackupScheduleData>
|
||||
> = {
|
||||
mutationFn: async (localOptions) => {
|
||||
const { data } = await upsertBackupSchedule({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const runBackupNowQueryKey = (options: Options<RunBackupNowData>) => createQueryKey("runBackupNow", options);
|
||||
|
||||
/**
|
||||
|
||||
@@ -68,8 +68,6 @@ import type {
|
||||
UpdateBackupScheduleResponses,
|
||||
GetBackupScheduleForVolumeData,
|
||||
GetBackupScheduleForVolumeResponses,
|
||||
UpsertBackupScheduleData,
|
||||
UpsertBackupScheduleResponses,
|
||||
RunBackupNowData,
|
||||
RunBackupNowResponses,
|
||||
} from "./types.gen";
|
||||
@@ -474,22 +472,6 @@ export const getBackupScheduleForVolume = <ThrowOnError extends boolean = false>
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Create or update a backup schedule for a volume
|
||||
*/
|
||||
export const upsertBackupSchedule = <ThrowOnError extends boolean = false>(
|
||||
options?: Options<UpsertBackupScheduleData, ThrowOnError>,
|
||||
) => {
|
||||
return (options?.client ?? _heyApiClient).put<UpsertBackupScheduleResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/backups/upsert",
|
||||
...options,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
...options?.headers,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Trigger a backup immediately for a schedule
|
||||
*/
|
||||
|
||||
@@ -782,7 +782,7 @@ export type ListSnapshotsData = {
|
||||
name: string;
|
||||
};
|
||||
query?: {
|
||||
volumeId?: string;
|
||||
backupId?: string;
|
||||
};
|
||||
url: "/api/v1/repositories/{name}/snapshots";
|
||||
};
|
||||
@@ -1181,11 +1181,11 @@ export type GetBackupScheduleResponse = GetBackupScheduleResponses[keyof GetBack
|
||||
|
||||
export type UpdateBackupScheduleData = {
|
||||
body?: {
|
||||
cronExpression?: string;
|
||||
cronExpression: string;
|
||||
repositoryId: string;
|
||||
enabled?: boolean;
|
||||
excludePatterns?: Array<string>;
|
||||
includePatterns?: Array<string>;
|
||||
repositoryId?: string;
|
||||
retentionPolicy?: {
|
||||
keepDaily?: number;
|
||||
keepHourly?: number;
|
||||
@@ -1342,62 +1342,6 @@ export type GetBackupScheduleForVolumeResponses = {
|
||||
export type GetBackupScheduleForVolumeResponse =
|
||||
GetBackupScheduleForVolumeResponses[keyof GetBackupScheduleForVolumeResponses];
|
||||
|
||||
export type UpsertBackupScheduleData = {
|
||||
body?: {
|
||||
cronExpression: string;
|
||||
enabled: boolean;
|
||||
repositoryId: string;
|
||||
volumeId: number;
|
||||
excludePatterns?: Array<string>;
|
||||
includePatterns?: Array<string>;
|
||||
retentionPolicy?: {
|
||||
keepDaily?: number;
|
||||
keepHourly?: number;
|
||||
keepLast?: number;
|
||||
keepMonthly?: number;
|
||||
keepWeekly?: number;
|
||||
keepWithinDuration?: string;
|
||||
keepYearly?: number;
|
||||
};
|
||||
tags?: Array<string>;
|
||||
};
|
||||
path?: never;
|
||||
query?: never;
|
||||
url: "/api/v1/backups/upsert";
|
||||
};
|
||||
|
||||
export type UpsertBackupScheduleResponses = {
|
||||
/**
|
||||
* Backup schedule upserted successfully
|
||||
*/
|
||||
200: {
|
||||
createdAt: number;
|
||||
cronExpression: string;
|
||||
enabled: boolean;
|
||||
excludePatterns: Array<string> | null;
|
||||
id: number;
|
||||
includePatterns: Array<string> | null;
|
||||
lastBackupAt: number | null;
|
||||
lastBackupError: string | null;
|
||||
lastBackupStatus: "error" | "success" | null;
|
||||
nextBackupAt: number | null;
|
||||
repositoryId: string;
|
||||
retentionPolicy: {
|
||||
keepDaily?: number;
|
||||
keepHourly?: number;
|
||||
keepLast?: number;
|
||||
keepMonthly?: number;
|
||||
keepWeekly?: number;
|
||||
keepWithinDuration?: string;
|
||||
keepYearly?: number;
|
||||
} | null;
|
||||
updatedAt: number;
|
||||
volumeId: number;
|
||||
};
|
||||
};
|
||||
|
||||
export type UpsertBackupScheduleResponse = UpsertBackupScheduleResponses[keyof UpsertBackupScheduleResponses];
|
||||
|
||||
export type RunBackupNowData = {
|
||||
body?: never;
|
||||
path: {
|
||||
|
||||
Reference in New Issue
Block a user