feat(backup): Add backup system: BackupManager, DB schema, API endpoints and UI support
Introduce a complete service backup/restore subsystem with encrypted archives, database records and REST endpoints. Implements BackupManager with export/import for service config, platform resources (MongoDB, MinIO, ClickHouse), and Docker images; adds BackupRepository and migrations for backups table and include_image_in_backup; integrates backup flows into the HTTP API and the UI client; exposes backup password management and restore modes (restore/import/clone). Wire BackupManager into Onebox initialization.
This commit is contained in:
67
ts/types.ts
67
ts/types.ts
@@ -23,6 +23,8 @@ export interface IService {
|
||||
imageDigest?: string;
|
||||
// Platform service requirements
|
||||
platformRequirements?: IPlatformRequirements;
|
||||
// Backup settings
|
||||
includeImageInBackup?: boolean;
|
||||
}
|
||||
|
||||
// Registry types
|
||||
@@ -317,3 +319,68 @@ export interface ICliArgs {
|
||||
_: string[];
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
// Backup types
|
||||
export type TBackupRestoreMode = 'restore' | 'import' | 'clone';
|
||||
|
||||
export interface IBackup {
|
||||
id?: number;
|
||||
serviceId: number;
|
||||
serviceName: string; // Denormalized for display
|
||||
filename: string;
|
||||
sizeBytes: number;
|
||||
createdAt: number;
|
||||
includesImage: boolean;
|
||||
platformResources: TPlatformServiceType[]; // Which platform types were backed up
|
||||
checksum: string;
|
||||
}
|
||||
|
||||
export interface IBackupManifest {
|
||||
version: string;
|
||||
createdAt: number;
|
||||
oneboxVersion: string;
|
||||
serviceName: string;
|
||||
includesImage: boolean;
|
||||
platformResources: TPlatformServiceType[];
|
||||
checksum: string;
|
||||
}
|
||||
|
||||
export interface IBackupServiceConfig {
|
||||
name: string;
|
||||
image: string;
|
||||
registry?: string;
|
||||
envVars: Record<string, string>;
|
||||
port: number;
|
||||
domain?: string;
|
||||
useOneboxRegistry?: boolean;
|
||||
registryRepository?: string;
|
||||
registryImageTag?: string;
|
||||
autoUpdateOnPush?: boolean;
|
||||
platformRequirements?: IPlatformRequirements;
|
||||
includeImageInBackup?: boolean;
|
||||
}
|
||||
|
||||
export interface IBackupPlatformResource {
|
||||
resourceType: TPlatformResourceType;
|
||||
resourceName: string;
|
||||
platformServiceType: TPlatformServiceType;
|
||||
credentials: Record<string, string>; // Decrypted for backup, re-encrypted on restore
|
||||
}
|
||||
|
||||
export interface IBackupResult {
|
||||
backup: IBackup;
|
||||
filePath: string;
|
||||
}
|
||||
|
||||
export interface IRestoreOptions {
|
||||
mode: TBackupRestoreMode;
|
||||
newServiceName?: string; // Required for 'import' and 'clone' modes
|
||||
skipPlatformData?: boolean; // Restore config only, skip DB/bucket data
|
||||
overwriteExisting?: boolean; // For 'restore' mode
|
||||
}
|
||||
|
||||
export interface IRestoreResult {
|
||||
service: IService;
|
||||
platformResourcesRestored: number;
|
||||
warnings: string[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user