feat: add backup replication contracts
This commit is contained in:
+36
-1
@@ -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';
|
export type TBackupTrigger = 'manual' | 'scheduled';
|
||||||
|
|
||||||
@@ -37,6 +45,32 @@ export type TBackupSnapshot =
|
|||||||
| IBackupDatabaseSnapshot
|
| IBackupDatabaseSnapshot
|
||||||
| IBackupObjectStorageSnapshot;
|
| 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 {
|
export interface IBackupRestoreEvent {
|
||||||
restoredAt: number;
|
restoredAt: number;
|
||||||
status: 'restored' | 'failed';
|
status: 'restored' | 'failed';
|
||||||
@@ -51,6 +85,7 @@ export interface IBackupRecord {
|
|||||||
status: TBackupStatus;
|
status: TBackupStatus;
|
||||||
trigger: TBackupTrigger;
|
trigger: TBackupTrigger;
|
||||||
snapshots: TBackupSnapshot[];
|
snapshots: TBackupSnapshot[];
|
||||||
|
replication?: IBackupReplicationResult;
|
||||||
createdAt: number;
|
createdAt: number;
|
||||||
updatedAt: number;
|
updatedAt: number;
|
||||||
completedAt?: number;
|
completedAt?: number;
|
||||||
|
|||||||
+95
-1
@@ -1,5 +1,11 @@
|
|||||||
import * as plugins from '../plugins.js';
|
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 { IService } from '../data/service.js';
|
||||||
import type { IIdentity } from '../data/user.js';
|
import type { IIdentity } from '../data/user.js';
|
||||||
|
|
||||||
@@ -78,9 +84,13 @@ extends plugins.typedrequestInterfaces.implementsTR<
|
|||||||
backupId: string;
|
backupId: string;
|
||||||
service: IService;
|
service: IService;
|
||||||
tags?: Record<string, string>;
|
tags?: Record<string, string>;
|
||||||
|
replication?: {
|
||||||
|
enabled: boolean;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
response: {
|
response: {
|
||||||
snapshots: TBackupSnapshot[];
|
snapshots: TBackupSnapshot[];
|
||||||
|
replication?: IBackupReplicationResult;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,8 +106,92 @@ extends plugins.typedrequestInterfaces.implementsTR<
|
|||||||
snapshots: TBackupSnapshot[];
|
snapshots: TBackupSnapshot[];
|
||||||
clear?: boolean;
|
clear?: boolean;
|
||||||
resourceTypes?: Array<TBackupSnapshot['type']>;
|
resourceTypes?: Array<TBackupSnapshot['type']>;
|
||||||
|
replication?: {
|
||||||
|
enabled: boolean;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
response: {
|
response: {
|
||||||
restored: TBackupSnapshot[];
|
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;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user