feat(backup): Add backup scheduling system with GFS retention, API and UI integration
This commit is contained in:
60
ts/types.ts
60
ts/types.ts
@@ -323,6 +323,24 @@ export interface ICliArgs {
|
||||
// Backup types
|
||||
export type TBackupRestoreMode = 'restore' | 'import' | 'clone';
|
||||
|
||||
// Retention policy for GFS (Grandfather-Father-Son) time-window based retention
|
||||
export interface IRetentionPolicy {
|
||||
hourly: number; // 0 = disabled, else keep up to N backups from last 24h
|
||||
daily: number; // Keep 1 backup per day for last N days
|
||||
weekly: number; // Keep 1 backup per week for last N weeks
|
||||
monthly: number; // Keep 1 backup per month for last N months
|
||||
}
|
||||
|
||||
// Default retention presets
|
||||
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;
|
||||
@@ -333,6 +351,8 @@ export interface IBackup {
|
||||
includesImage: boolean;
|
||||
platformResources: TPlatformServiceType[]; // Which platform types were backed up
|
||||
checksum: string;
|
||||
// Scheduled backup fields
|
||||
scheduleId?: number; // Links backup to its schedule for retention
|
||||
}
|
||||
|
||||
export interface IBackupManifest {
|
||||
@@ -384,3 +404,43 @@ export interface IRestoreResult {
|
||||
platformResourcesRestored: number;
|
||||
warnings: string[];
|
||||
}
|
||||
|
||||
// Backup scheduling types (GFS retention scheme)
|
||||
export type TBackupScheduleScope = 'all' | 'pattern' | 'service';
|
||||
|
||||
export interface IBackupSchedule {
|
||||
id?: number;
|
||||
scopeType: TBackupScheduleScope;
|
||||
scopePattern?: string; // Glob pattern for 'pattern' scope type
|
||||
serviceId?: number; // Only for 'service' scope type
|
||||
serviceName?: string; // Only for 'service' scope type
|
||||
cronExpression: string;
|
||||
retention: IRetentionPolicy; // Per-tier retention counts
|
||||
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; // Required for 'pattern' scope type
|
||||
serviceName?: string; // Required for 'service' scope type
|
||||
cronExpression: string;
|
||||
retention: IRetentionPolicy;
|
||||
enabled?: boolean;
|
||||
}
|
||||
|
||||
export interface IBackupScheduleUpdate {
|
||||
cronExpression?: string;
|
||||
retention?: IRetentionPolicy;
|
||||
enabled?: boolean;
|
||||
}
|
||||
|
||||
// Backup creation options (for scheduled backups)
|
||||
export interface IBackupCreateOptions {
|
||||
scheduleId?: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user