Docker images / prepare-release (push) Successful in 9s
Docker images / backend-test (push) Successful in 2m18s
Docker images / frontend-image (push) Successful in 4m37s
Docker images / updater-image (push) Successful in 46s
Docker images / backend-image (push) Successful in 3m6s
Docker images / notify-webhook (push) Skipped
Docker images / publish-release (push) Successful in 16s
Сохранять снимки в S3-compatible бакет, скачивать и удалять их вместе с локальными файлами. Привести /backups к DNA /servers: Frame, KPI, фильтры и реальное восстановление. Co-authored-by: Cursor <[email protected]>
123 lines
3.7 KiB
TypeScript
123 lines
3.7 KiB
TypeScript
import { requestJson } from "@/shared/api/http-client"
|
|
import type {
|
|
BackupScheduleSettingsDto,
|
|
BackupStorageSettingsDto,
|
|
PutBackupStorageSettings,
|
|
} from "@mmapp/contracts/backups"
|
|
|
|
export type BackupItem = {
|
|
id: string
|
|
serverId: number | string | null
|
|
serverName: string
|
|
filename: string
|
|
sizeBytes: number
|
|
createdAt: string
|
|
kind: "manual" | "auto"
|
|
notes?: string
|
|
storage?: "local" | "s3" | "both"
|
|
s3Key?: string | null
|
|
uploadError?: string | null
|
|
}
|
|
|
|
type CreateBackupResponse = {
|
|
created: BackupItem[]
|
|
failures: Array<{ serverId: string; error: string }>
|
|
}
|
|
|
|
export type CreateBackupJobResponse = {
|
|
jobId: string
|
|
status: "queued" | "running" | "done" | "failed"
|
|
total: number
|
|
completed: number
|
|
}
|
|
|
|
export type BackupJobStatusResponse = {
|
|
id: string
|
|
status: "queued" | "running" | "done" | "failed"
|
|
requestedAt: string
|
|
startedAt?: string
|
|
finishedAt?: string
|
|
total: number
|
|
completed: number
|
|
created: BackupItem[]
|
|
failures: Array<{ serverId: string; error: string }>
|
|
}
|
|
|
|
export async function listBackups(baseUrl: string): Promise<BackupItem[]> {
|
|
return requestJson<BackupItem[]>(baseUrl, "/api/backups")
|
|
}
|
|
|
|
export async function createBackups(
|
|
baseUrl: string,
|
|
payload: { serverIds: string[]; notes?: string },
|
|
): Promise<CreateBackupResponse> {
|
|
return requestJson<CreateBackupResponse>(baseUrl, "/api/backups/create", {
|
|
method: "POST",
|
|
body: JSON.stringify(payload),
|
|
})
|
|
}
|
|
|
|
export async function createBackupsAsync(
|
|
baseUrl: string,
|
|
payload: { serverIds: string[]; notes?: string },
|
|
): Promise<CreateBackupJobResponse> {
|
|
return requestJson<CreateBackupJobResponse>(baseUrl, "/api/backups/create", {
|
|
method: "POST",
|
|
body: JSON.stringify(payload),
|
|
})
|
|
}
|
|
|
|
export async function getBackupJob(baseUrl: string, jobId: string): Promise<BackupJobStatusResponse> {
|
|
return requestJson<BackupJobStatusResponse>(baseUrl, `/api/backups/jobs/${jobId}`)
|
|
}
|
|
|
|
export async function deleteBackup(baseUrl: string, id: string): Promise<void> {
|
|
await requestJson<void>(baseUrl, `/api/backups/${id}`, { method: "DELETE" })
|
|
}
|
|
|
|
export async function restoreBackup(baseUrl: string, id: string): Promise<{ filename: string; serverName: string }> {
|
|
return requestJson<{ filename: string; serverName: string }>(baseUrl, `/api/backups/${id}/restore`, {
|
|
method: "POST",
|
|
})
|
|
}
|
|
|
|
export async function getBackupScheduleSettings(baseUrl: string): Promise<BackupScheduleSettingsDto> {
|
|
return requestJson<BackupScheduleSettingsDto>(baseUrl, "/api/backups/schedule")
|
|
}
|
|
|
|
export async function putBackupScheduleSettings(
|
|
baseUrl: string,
|
|
payload: Partial<BackupScheduleSettingsDto>,
|
|
): Promise<BackupScheduleSettingsDto> {
|
|
return requestJson<BackupScheduleSettingsDto>(baseUrl, "/api/backups/schedule", {
|
|
method: "PUT",
|
|
body: JSON.stringify(payload),
|
|
})
|
|
}
|
|
|
|
export async function getBackupStorageSettings(baseUrl: string): Promise<BackupStorageSettingsDto> {
|
|
return requestJson<BackupStorageSettingsDto>(baseUrl, "/api/backups/storage")
|
|
}
|
|
|
|
export async function putBackupStorageSettings(
|
|
baseUrl: string,
|
|
payload: PutBackupStorageSettings,
|
|
): Promise<BackupStorageSettingsDto> {
|
|
return requestJson<BackupStorageSettingsDto>(baseUrl, "/api/backups/storage", {
|
|
method: "PUT",
|
|
body: JSON.stringify(payload),
|
|
})
|
|
}
|
|
|
|
export async function testBackupStorage(baseUrl: string): Promise<BackupStorageSettingsDto> {
|
|
return requestJson<BackupStorageSettingsDto>(baseUrl, "/api/backups/storage/test", { method: "POST" })
|
|
}
|
|
|
|
export async function syncBackupsFromStorage(
|
|
baseUrl: string,
|
|
): Promise<{ imported: number; skipped: number }> {
|
|
return requestJson<{ imported: number; skipped: number }>(baseUrl, "/api/backups/storage/sync", {
|
|
method: "POST",
|
|
})
|
|
}
|