From 6f1bc574fd1a9dea9c7c8c8936536a8011272490 Mon Sep 17 00:00:00 2001 From: Juergen Kunz Date: Thu, 7 May 2026 17:44:31 +0000 Subject: [PATCH] feat: add backup replication contracts --- ts/data/backup.ts | 37 ++++++++++++++++- ts/requests/backup.ts | 96 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 131 insertions(+), 2 deletions(-) diff --git a/ts/data/backup.ts b/ts/data/backup.ts index 4540ed3..baa0147 100644 --- a/ts/data/backup.ts +++ b/ts/data/backup.ts @@ -1,4 +1,12 @@ -export type TBackupStatus = 'pending' | 'running' | 'ready' | 'failed' | 'restoring' | 'restored'; +export type TBackupStatus = + | 'pending' + | 'running' + | 'replicating' + | 'replicated' + | 'ready' + | 'failed' + | 'restoring' + | 'restored'; export type TBackupTrigger = 'manual' | 'scheduled'; @@ -37,6 +45,32 @@ export type TBackupSnapshot = | IBackupDatabaseSnapshot | IBackupObjectStorageSnapshot; +export type TBackupReplicationTargetType = 's3' | 'smb'; + +export interface IBackupArchiveObject { + path: string; + size: number; + sha256: string; +} + +export interface IBackupArchiveManifest { + version: 1; + backupId: string; + createdAt: number; + objects: IBackupArchiveObject[]; + totalSize: number; +} + +export interface IBackupReplicationResult { + targetType: TBackupReplicationTargetType; + targetPath: string; + manifestPath: string; + manifestSha256: string; + objectCount: number; + totalSize: number; + completedAt: number; +} + export interface IBackupRestoreEvent { restoredAt: number; status: 'restored' | 'failed'; @@ -51,6 +85,7 @@ export interface IBackupRecord { status: TBackupStatus; trigger: TBackupTrigger; snapshots: TBackupSnapshot[]; + replication?: IBackupReplicationResult; createdAt: number; updatedAt: number; completedAt?: number; diff --git a/ts/requests/backup.ts b/ts/requests/backup.ts index 05a252a..7d4336a 100644 --- a/ts/requests/backup.ts +++ b/ts/requests/backup.ts @@ -1,5 +1,11 @@ import * as plugins from '../plugins.js'; -import type { IBackupRecord, TBackupSnapshot } from '../data/backup.js'; +import type { + IBackupArchiveManifest, + IBackupArchiveObject, + IBackupRecord, + IBackupReplicationResult, + TBackupSnapshot, +} from '../data/backup.js'; import type { IService } from '../data/service.js'; import type { IIdentity } from '../data/user.js'; @@ -78,9 +84,13 @@ extends plugins.typedrequestInterfaces.implementsTR< backupId: string; service: IService; tags?: Record; + replication?: { + enabled: boolean; + }; }; response: { snapshots: TBackupSnapshot[]; + replication?: IBackupReplicationResult; }; } @@ -96,8 +106,92 @@ extends plugins.typedrequestInterfaces.implementsTR< snapshots: TBackupSnapshot[]; clear?: boolean; resourceTypes?: Array; + replication?: { + enabled: boolean; + }; }; response: { restored: TBackupSnapshot[]; }; } + +export interface IReq_Coreflow_Cloudly_PrepareBackupReplication +extends plugins.typedrequestInterfaces.implementsTR< + plugins.typedrequestInterfaces.ITypedRequest, + IReq_Coreflow_Cloudly_PrepareBackupReplication +> { + method: 'prepareBackupReplication'; + request: { + identity: IIdentity; + backupId: string; + manifest: IBackupArchiveManifest; + }; + response: { + missingObjects: IBackupArchiveObject[]; + }; +} + +export interface IReq_Coreflow_Cloudly_UploadBackupArchiveObject +extends plugins.typedrequestInterfaces.implementsTR< + plugins.typedrequestInterfaces.ITypedRequest, + IReq_Coreflow_Cloudly_UploadBackupArchiveObject +> { + method: 'uploadBackupArchiveObject'; + request: { + identity: IIdentity; + backupId: string; + object: IBackupArchiveObject; + contentsBase64: string; + }; + response: { + accepted: boolean; + }; +} + +export interface IReq_Coreflow_Cloudly_CompleteBackupReplication +extends plugins.typedrequestInterfaces.implementsTR< + plugins.typedrequestInterfaces.ITypedRequest, + IReq_Coreflow_Cloudly_CompleteBackupReplication +> { + method: 'completeBackupReplication'; + request: { + identity: IIdentity; + backupId: string; + manifest: IBackupArchiveManifest; + }; + response: { + replication: IBackupReplicationResult; + }; +} + +export interface IReq_Coreflow_Cloudly_GetBackupArchiveManifest +extends plugins.typedrequestInterfaces.implementsTR< + plugins.typedrequestInterfaces.ITypedRequest, + IReq_Coreflow_Cloudly_GetBackupArchiveManifest +> { + method: 'getBackupArchiveManifest'; + request: { + identity: IIdentity; + backupId: string; + }; + response: { + manifest: IBackupArchiveManifest; + }; +} + +export interface IReq_Coreflow_Cloudly_DownloadBackupArchiveObject +extends plugins.typedrequestInterfaces.implementsTR< + plugins.typedrequestInterfaces.ITypedRequest, + IReq_Coreflow_Cloudly_DownloadBackupArchiveObject +> { + method: 'downloadBackupArchiveObject'; + request: { + identity: IIdentity; + backupId: string; + object: IBackupArchiveObject; + }; + response: { + object: IBackupArchiveObject; + contentsBase64: string; + }; +}