Validate backups before restore

This commit is contained in:
2026-08-06 08:28:01 +02:00
parent 72229cf14c
commit 05c842e406
7 changed files with 347 additions and 56 deletions
+20
View File
@@ -32,6 +32,12 @@ type DeleteSessionResult = {
};
};
export type RestoreValidationResult = {
valid: boolean;
checkedTables: number;
issues: string[];
};
export class ApiError extends Error {
constructor(
message: string,
@@ -107,6 +113,13 @@ export function restoreSetupBackup(sql: string) {
});
}
export function validateSetupBackup(sql: string) {
return request<RestoreValidationResult>("/api/setup/restore/validate", {
method: "POST",
body: JSON.stringify({ sql })
});
}
export function getAdminUsers() {
return request<{ users: AdminUser[] }>("/api/admin/users");
}
@@ -164,6 +177,13 @@ export function restoreDatabaseBackup(sql: string) {
});
}
export function validateDatabaseBackup(sql: string) {
return request<RestoreValidationResult>("/api/admin/restore/database/validate", {
method: "POST",
body: JSON.stringify({ sql })
});
}
export async function downloadMonthExport(month: string) {
const response = await fetch(`/api/export/months/${month}`, {
credentials: "same-origin"