90 lines
2.0 KiB
TypeScript
90 lines
2.0 KiB
TypeScript
/**
|
|
* Backup-related data shapes for Onebox
|
|
*/
|
|
|
|
import type { TPlatformServiceType } from './platform.ts';
|
|
|
|
export type TBackupRestoreMode = 'restore' | 'import' | 'clone';
|
|
export type TBackupScheduleScope = 'all' | 'pattern' | 'service';
|
|
|
|
export interface IRetentionPolicy {
|
|
hourly: number;
|
|
daily: number;
|
|
weekly: number;
|
|
monthly: number;
|
|
}
|
|
|
|
export const RETENTION_PRESETS = {
|
|
standard: { hourly: 0, daily: 7, weekly: 4, monthly: 12 },
|
|
frequent: { hourly: 24, daily: 7, weekly: 4, monthly: 12 },
|
|
minimal: { hourly: 0, daily: 3, weekly: 2, monthly: 6 },
|
|
longterm: { hourly: 0, daily: 14, weekly: 8, monthly: 24 },
|
|
} as const;
|
|
|
|
export type TRetentionPreset = keyof typeof RETENTION_PRESETS | 'custom';
|
|
|
|
export interface IBackup {
|
|
id?: number;
|
|
serviceId: number;
|
|
serviceName: string;
|
|
filename: string;
|
|
sizeBytes: number;
|
|
createdAt: number;
|
|
includesImage: boolean;
|
|
platformResources: TPlatformServiceType[];
|
|
checksum: string;
|
|
scheduleId?: number;
|
|
}
|
|
|
|
export interface IBackupSchedule {
|
|
id?: number;
|
|
scopeType: TBackupScheduleScope;
|
|
scopePattern?: string;
|
|
serviceId?: number;
|
|
serviceName?: string;
|
|
cronExpression: string;
|
|
retention: IRetentionPolicy;
|
|
enabled: boolean;
|
|
lastRunAt: number | null;
|
|
nextRunAt: number | null;
|
|
lastStatus: 'success' | 'failed' | null;
|
|
lastError: string | null;
|
|
createdAt: number;
|
|
updatedAt: number;
|
|
}
|
|
|
|
export interface IBackupScheduleCreate {
|
|
scopeType: TBackupScheduleScope;
|
|
scopePattern?: string;
|
|
serviceName?: string;
|
|
cronExpression: string;
|
|
retention: IRetentionPolicy;
|
|
enabled?: boolean;
|
|
}
|
|
|
|
export interface IBackupScheduleUpdate {
|
|
cronExpression?: string;
|
|
retention?: IRetentionPolicy;
|
|
enabled?: boolean;
|
|
}
|
|
|
|
export interface IRestoreOptions {
|
|
mode: TBackupRestoreMode;
|
|
newServiceName?: string;
|
|
overwriteExisting?: boolean;
|
|
skipPlatformData?: boolean;
|
|
}
|
|
|
|
export interface IRestoreResult {
|
|
service: {
|
|
name: string;
|
|
status: string;
|
|
};
|
|
platformResourcesRestored: number;
|
|
warnings: string[];
|
|
}
|
|
|
|
export interface IBackupPasswordStatus {
|
|
isConfigured: boolean;
|
|
}
|