Validate backups before restore
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user