A modern, self-hosted backup solution for secure, encrypted backups across local and cloud storage.
chore: facilitate VM backup plans feature for pluton biz
towfiqi7f93c0b5946a
diff --git a/backend/__tests__/managers/BaseBackupManager.test.ts b/backend/__tests__/managers/BaseBackupManager.test.tsindex c4c370b..fc91229 100644--- a/backend/__tests__/managers/BaseBackupManager.test.ts+++ b/backend/__tests__/managers/BaseBackupManager.test.ts@@ -30,6 +30,11 @@ jest.mock('../../src/utils/rclone/rclone', () => ({runRcloneCommand: (...args: any[]) => (mockRunRcloneCommand as any)(...args),}));+const mockCanWriteTargetOrParent = jest.fn().mockResolvedValue(true);+jest.mock('../../src/utils/linuxHelper', () => ({+ canWriteTargetOrParent: (...args: any[]) => mockCanWriteTargetOrParent(...args),+}));+// Mock singleton instance for CronManagerconst mockCronManagerInstance = {scheduleTask: (...args: any[]) => mockScheduleTask(...args),@@ -449,6 +454,27 @@ describe('BaseBackupManager', () => {expect(mockScheduleTask).not.toHaveBeenCalled();});+ it('refuses a local destination the service user cannot write, before the repo init', async () => {+ mockCanWriteTargetOrParent.mockResolvedValueOnce(false);+ const localOptions = {+ ...baseOptions,+ storage: { ...baseOptions.storage, type: 'local' },+ storagePath: '/home/pluton-storage',+ };+ const res = await mgr.createBackup('plan-local', localOptions as BackupPlanArgs);+ expect(res.success).toBe(false);+ expect(res.result).toMatch(/cannot write to "\/home\/pluton-storage"/);+ expect(mockCanWriteTargetOrParent).toHaveBeenCalledWith('/home/pluton-storage');+ expect(mockRunResticCommand).not.toHaveBeenCalled();+ });++ it('does not check write access for a remote destination', async () => {+ mockCanWriteTargetOrParent.mockClear();+ mockRunResticCommand.mockRejectedValueOnce(new Error('init failed'));+ await mgr.createBackup('plan-abc', baseOptions as BackupPlanArgs);+ expect(mockCanWriteTargetOrParent).not.toHaveBeenCalled();+ });+it('handles encrypted backup creation', async () => {const encryptedOptions = {...baseOptions,diff --git a/backend/__tests__/managers/BaseRestoreManager.test.ts b/backend/__tests__/managers/BaseRestoreManager.test.tsindex 9688f16..0b6c131 100644--- a/backend/__tests__/managers/BaseRestoreManager.test.ts+++ b/backend/__tests__/managers/BaseRestoreManager.test.ts@@ -27,6 +27,24 @@ describe('BaseRestoreManager', () => {expect(manager).toBeInstanceOf(EventEmitter);expect((manager as any).restoreHandler).toBeInstanceOf(RestoreHandler);});++ it('should use a subclass restoreHandler getter override', async () => {+ const custom = { execute: jest.fn().mockResolvedValue('custom') };+ class CustomRestoreManager extends BaseRestoreManager {+ get restoreHandler(): RestoreHandler {+ return custom as unknown as RestoreHandler;+ }+ }+ const retryInfo = { attempts: 0, maxAttempts: 1 };+ const result = await new CustomRestoreManager().performRestoreExecution(+ 'b1',+ 'r1',+ {} as RestoreOptions,+ retryInfo+ );+ expect(custom.execute).toHaveBeenCalledWith('b1', 'r1', {}, retryInfo);+ expect(result).toBe('custom');+ });});describe('performRestoreExecution', () => {diff --git a/backend/__tests__/managers/handlers/RestoreHandler.test.ts b/backend/__tests__/managers/handlers/RestoreHandler.test.tsindex 0e481a1..aa7dd57 100644--- a/backend/__tests__/managers/handlers/RestoreHandler.test.ts+++ b/backend/__tests__/managers/handlers/RestoreHandler.test.ts@@ -1047,6 +1047,27 @@ describe('RestoreHandler', () => {);expect(unlockCall).toBeDefined();});++ it('should pass options.extra into the restore_start config', async () => {+ const extra = { vm: { mode: 'stream' } };+ let startConfig: any;+ emitter.on('restore_start', (data: any) => {+ startConfig = data.config;+ setImmediate(() =>+ emitter.emit('restoreCreated', { backupId: 'backup-1', restoreId: 'restore-1' })+ );+ });+ mockRunResticCommand.mockResolvedValueOnce(+ JSON.stringify({ message_type: 'summary', total_files: 1, total_bytes: 1 })+ );++ await handler['preRestorePhase']('plan-1', 'backup-1', 'restore-1', {+ ...baseOptions,+ extra,+ });++ expect(startConfig.extra).toEqual(extra);+ });});describe('updateProgress', () => {diff --git a/backend/__tests__/services/DeviceService.test.ts b/backend/__tests__/services/DeviceService.test.tsindex 8897e45..44a39ac 100644--- a/backend/__tests__/services/DeviceService.test.ts+++ b/backend/__tests__/services/DeviceService.test.ts@@ -158,6 +158,33 @@ describe('DeviceService', () => {});});+ // ----------------------------------------+ // getMetrics+ // ----------------------------------------+ describe('getMetrics', () => {+ const mockMetrics = { system: { manufacturer: 'Dell' }, os: {} } as DeviceMetrics;++ it('should call the strategy with no payload by default', async () => {+ mockDeviceStore.getById.mockResolvedValue({ id: 'main' } as Device);+ mockLocalStrategy.getMetrics.mockResolvedValue({ success: true, result: mockMetrics as any });++ const result = await deviceService.getMetrics('main');++ expect(mockLocalStrategy.getMetrics).toHaveBeenCalledWith(undefined);+ expect(result).toEqual(mockMetrics);+ });++ it('should pass the options to the strategy', async () => {+ const options = { extra: true };+ mockDeviceStore.getById.mockResolvedValue({ id: 'remote-1' } as Device);+ mockRemoteStrategy.getMetrics.mockResolvedValue({ success: true, result: mockMetrics as any });++ await deviceService.getMetrics('remote-1', options);++ expect(mockRemoteStrategy.getMetrics).toHaveBeenCalledWith(options);+ });+ });+// ----------------------------------------// updateDevice// ----------------------------------------diff --git a/backend/__tests__/services/RestoreEventService.test.ts b/backend/__tests__/services/RestoreEventService.test.tsindex 4047e17..5aeafb9 100644--- a/backend/__tests__/services/RestoreEventService.test.ts+++ b/backend/__tests__/services/RestoreEventService.test.ts@@ -12,6 +12,7 @@ import { RestoreStore } from '../../src/stores/RestoreStore';import { BaseRestoreManager } from '../../src/managers/BaseRestoreManager';import { RestoreStartEvent, RestoreCompleteEvent, RestoreErrorEvent } from '../../src/types/events';import * as fsPromises from 'fs/promises';+import { registerRestoreCompleteHook } from '../../src/services/events/restoreHooks';jest.mock('../../src/db/index', () => ({db: {@@ -114,6 +115,23 @@ describe('RestoreEventService', () => {expect(mockLocalAgent.emit).toHaveBeenCalledWith('restoreCreated', { backupId, restoreId });});+ it('should store config.extra in the restore record', async () => {+ mockBackupStore.getById.mockResolvedValue(mockBackup);+ mockRestoreStore.create.mockImplementation(data =>+ Promise.resolve({ ...data, id: restoreId } as any)+ );+ const extra = { vm: { mode: 'stream' } };++ await restoreEventService.onRestoreStart({+ ...startEvent,+ config: { ...startEvent.config, extra },+ });++ expect(mockRestoreStore.create).toHaveBeenCalledWith(+ expect.objectContaining({ config: { ...startEvent.config, extra } })+ );+ });+it('should log an error and not create a record if the backup is not found', async () => {// ArrangemockBackupStore.getById.mockResolvedValue(null);@@ -321,5 +339,72 @@ describe('RestoreEventService', () => {completionStats: undefined, // Should be undefined as file read failed});});++ it('should merge the event extra into config.extra on success', async () => {+ (fsPromises.readFile as jest.Mock).mockResolvedValue('{}');+ mockRestoreStore.getById.mockResolvedValue({+ id: restoreId,+ config: { target: '', includes: ['/a'], extra: { vm: { mode: 'stream' } } },+ } as any);+ mockRestoreStore.update.mockResolvedValue({ id: restoreId } as any);++ await restoreEventService.onRestoreComplete({ ...completeEvent, extra: { vmid: '105' } });++ expect(mockRestoreStore.update).toHaveBeenCalledWith(+ restoreId,+ expect.objectContaining({+ status: 'completed',+ config: { target: '', includes: ['/a'], extra: { vm: { mode: 'stream' }, vmid: '105' } },+ })+ );+ });++ it('should ignore the event extra when the restore failed', async () => {+ (fsPromises.readFile as jest.Mock).mockResolvedValue('{}');+ mockRestoreStore.getById.mockResolvedValue({ id: restoreId, status: 'started' } as any);+ mockRestoreStore.update.mockResolvedValue({ id: restoreId } as any);++ await restoreEventService.onRestoreComplete({ ...completeEvent, success: false, extra: { vmid: '105' } });++ expect(mockRestoreStore.update).toHaveBeenCalledWith(+ restoreId,+ expect.not.objectContaining({ config: expect.anything() })+ );+ });++ describe('completion hooks', () => {+ const hook = jest.fn();+ const flush = () => new Promise(resolve => setImmediate(resolve));++ beforeAll(() => registerRestoreCompleteHook(hook));++ it('should run the hooks once with the updated row on success', async () => {+ // Arrange+ (fsPromises.readFile as jest.Mock).mockResolvedValue('{}');+ const row = { id: restoreId, status: 'completed' } as any;+ mockRestoreStore.update.mockResolvedValue(row);++ // Act+ await restoreEventService.onRestoreComplete(completeEvent);+ await flush();++ // Assert+ expect(hook).toHaveBeenCalledTimes(1);+ expect(hook).toHaveBeenCalledWith(row);+ });++ it('should not run the hooks on failure', async () => {+ // Arrange+ (fsPromises.readFile as jest.Mock).mockResolvedValue('{}');+ mockRestoreStore.update.mockResolvedValue({ id: restoreId, status: 'failed' } as any);++ // Act+ await restoreEventService.onRestoreComplete({ ...completeEvent, success: false });+ await flush();++ // Assert+ expect(hook).not.toHaveBeenCalled();+ });+ });});});diff --git a/backend/__tests__/services/RestoreService.test.ts b/backend/__tests__/services/RestoreService.test.tsindex 7a320f6..305cc14 100644--- a/backend/__tests__/services/RestoreService.test.ts+++ b/backend/__tests__/services/RestoreService.test.ts@@ -187,6 +187,23 @@ describe('RestoreService', () => {expect(result).toEqual({ stats: 'some-stats' });});+ it('should pass restoreConfig.extra to the strategy', async () => {+ mockBackupStore.getById.mockResolvedValue(mockBackup);+ mockRestoreStore.isRestoreRunning.mockResolvedValue(false);+ mockPlanStore.getById.mockResolvedValue({ id: 'plan-1', settings: {} } as any);+ mockStorageStore.getById.mockResolvedValue(mockStorage);+ mockRestoreStrategy.getRestoreSnapshotStats.mockResolvedValue({ success: true, result: {} });+ const extra = { vm: { mode: 'stream' } };++ await restoreService.dryRestoreBackup(backupId, { ...restoreConfig, extra } as any);++ expect(mockRestoreStrategy.getRestoreSnapshotStats).toHaveBeenCalledWith(+ mockBackup.planId,+ backupId,+ expect.objectContaining({ extra })+ );+ });+it('should throw an error if backup is not found', async () => {// ArrangemockBackupStore.getById.mockResolvedValue(null);@@ -253,6 +270,23 @@ describe('RestoreService', () => {expect(result).toBe('Restore started');});+ it('should pass restoreConfig.extra to the strategy', async () => {+ mockBackupStore.getById.mockResolvedValue(mockBackup);+ mockPlanStore.getById.mockResolvedValue(mockPlan);+ mockRestoreStore.isRestoreRunning.mockResolvedValue(false);+ mockStorageStore.getById.mockResolvedValue(mockStorage);+ mockRestoreStrategy.restoreSnapshot.mockResolvedValue({ success: true, result: 'ok' });+ const extra = { vm: { mode: 'stream' } };++ await restoreService.restoreBackup(backupId, { ...restoreConfig, extra } as any);++ expect(mockRestoreStrategy.restoreSnapshot).toHaveBeenCalledWith(+ mockBackup.planId,+ backupId,+ expect.objectContaining({ extra })+ );+ });+it('should throw an error if the backup is not found', async () => {// ArrangemockBackupStore.getById.mockResolvedValue(null);diff --git a/backend/__tests__/stores/RestoreStore.test.ts b/backend/__tests__/stores/RestoreStore.test.tsindex d8e7cd1..e062938 100644--- a/backend/__tests__/stores/RestoreStore.test.ts+++ b/backend/__tests__/stores/RestoreStore.test.ts@@ -217,6 +217,21 @@ describe('RestoreStore', () => {}));});++ it('should keep the `ended` timestamp when the update has no status', async () => {+ // Arrange+ const restoreId = 'restore-2';+ const updates = { config: { target: '/tmp/x' } as any };+ mockDb.update().returning.mockResolvedValue([{ ...mockRestores[1], ...updates }]);++ // Act+ await restoreStore.update(restoreId, updates);++ // Assert+ const setArg = mockDb.update().set.mock.calls.at(-1)[0];+ expect(setArg).toEqual(expect.objectContaining({ ...updates, updatedAt: expect.any(Object) }));+ expect('ended' in setArg).toBe(false);+ });});describe('isRestoreRunning', () => {diff --git a/backend/__tests__/utils/restic/restic.test.ts b/backend/__tests__/utils/restic/restic.test.tsindex 4e00929..fbf087c 100644--- a/backend/__tests__/utils/restic/restic.test.ts+++ b/backend/__tests__/utils/restic/restic.test.ts@@ -1,4 +1,5 @@import { EventEmitter } from 'events';+import { PassThrough, Writable } from 'stream';// Mock modules BEFORE importing the function under testjest.mock('child_process');@@ -393,6 +394,39 @@ describe('runResticCommand', () => {expect(onProgress).toHaveBeenCalled();});+ it('should pipe raw stdout to options.stdout without buffering or parsing', async () => {+ mockProcess.stdout = new PassThrough();+ const received: Buffer[] = [];+ const sink = new Writable({+ write(chunk, _enc, cb) {+ received.push(chunk);+ cb();+ },+ });+ const onProgress = jest.fn();++ const promise = runResticCommand(+ ['dump', 'abc123', '/vzdump-qemu-100.vma'],+ {},+ onProgress,+ undefined,+ undefined,+ undefined,+ { stdout: sink }+ );++ const raw = Buffer.from([0x00, 0xff, 0x7b, 0x7d]);+ mockProcess.stdout.write(raw);+ mockProcess.stdout.end();+ await new Promise(resolve => sink.on('finish', resolve));+ mockProcess.emit('close', 0);++ const result = await promise;+ expect(result).toBe('');+ expect(Buffer.concat(received)).toEqual(raw);+ expect(onProgress).not.toHaveBeenCalled();+ });+it('should keep only the summary line for streaming backup dry runs', async () => {const onProgress = jest.fn();const statusData = JSON.stringify({diff --git a/backend/src/managers/BaseBackupManager.ts b/backend/src/managers/BaseBackupManager.tsindex e68a1cc..746d511 100644--- a/backend/src/managers/BaseBackupManager.ts+++ b/backend/src/managers/BaseBackupManager.ts@@ -17,6 +17,7 @@ import { jobQueue } from '../jobs/JobQueue';import { jobProcessor } from '../jobs/JobProcessor';import { generateUID } from '../utils/helpers';import { configService } from '../services/ConfigService';+import { canWriteTargetOrParent } from '../utils/linuxHelper';import { BackupRunConfig } from '../types/backups';type ScheduleOptions = (BackupPlanArgs | PlanPrune) & {@@ -77,6 +78,13 @@ export class BaseBackupManager extends EventEmitter {result: 'Encryption is enabled but ENCRYPTION_KEY is not set in environment variables.',};}+ // The service user (not root) creates the repo, thus a local path must be writable by it.+ if (storage.type === 'local' && storagePath && !(await canWriteTargetOrParent(storagePath))) {+ return {+ success: false,+ result: `Pluton cannot write to "${storagePath}". Give the user that runs the Pluton service write access to this folder (for example: chown pluton:pluton <folder>), then create the plan again.`,+ };+ }// Then Create a restic repo based on the provided rclone storage and the backup pathconst repoPassword = encryption ? encKey : '';try {diff --git a/backend/src/managers/BaseRestoreManager.ts b/backend/src/managers/BaseRestoreManager.tsindex 14bd72d..aa614e7 100644--- a/backend/src/managers/BaseRestoreManager.ts+++ b/backend/src/managers/BaseRestoreManager.ts@@ -6,10 +6,13 @@ import { jobQueue } from '../jobs/JobQueue';import { RestoreOptions } from '../types/restores';export class BaseRestoreManager extends EventEmitter {- private restoreHandler: RestoreHandler;- constructor() {- super();- this.restoreHandler = new RestoreHandler(this);+ protected _restoreHandler?: RestoreHandler;++ get restoreHandler(): RestoreHandler {+ if (!this._restoreHandler) {+ this._restoreHandler = new RestoreHandler(this);+ }+ return this._restoreHandler;}/**diff --git a/backend/src/managers/handlers/RestoreHandler.ts b/backend/src/managers/handlers/RestoreHandler.tsindex c414add..0bdbed0 100644--- a/backend/src/managers/handlers/RestoreHandler.ts+++ b/backend/src/managers/handlers/RestoreHandler.ts@@ -35,7 +35,7 @@ export class RestoreHandler {private progressManager: ProgressManager;private restoreStatsManager: RestoreStatsManager;- constructor(private emitter: EventEmitter) {+ constructor(protected emitter: EventEmitter) {this.progressManager = new ProgressManager(appPaths.getProgressDir(), 'restore');this.restoreStatsManager = new RestoreStatsManager();this.initializeProgressManager();@@ -231,6 +231,7 @@ export class RestoreHandler {overwrite: options.overwrite,includes: options.includes,excludes: options.excludes,+ extra: options.extra,},});@@ -275,7 +276,7 @@ export class RestoreHandler {/*** Restore phase: executes the actual restic restore command.*/- private async executeRestorePhase(+ protected async executeRestorePhase(planId: string,backupId: string,restoreId: string,@@ -717,7 +718,7 @@ export class RestoreHandler {}}- private createHandlers(planId: string, backupId: string, restoreId: string) {+ protected createHandlers(planId: string, backupId: string, restoreId: string) {return {onProgress: (data: Buffer) => {const progressLine = data.toString().trim();diff --git a/backend/src/services/DeviceService.ts b/backend/src/services/DeviceService.tsindex 99c9dda..25d47ed 100644--- a/backend/src/services/DeviceService.ts+++ b/backend/src/services/DeviceService.ts@@ -158,14 +158,14 @@ export class DeviceService {return device;}- async getMetrics(id: string): Promise<DeviceMetrics | null> {+ async getMetrics(id: string, options?: Record<string, any>): Promise<DeviceMetrics | null> {const device = await this.deviceStore.getById(id);if (!device) {throw new Error('Device not found.');}const strategy = this.getSystemStrategy(id);- const response = await strategy.getMetrics();+ const response = await strategy.getMetrics(options);if (!response.success) {throw new Error('Failed to get Device metrics');}diff --git a/backend/src/services/PlanService.ts b/backend/src/services/PlanService.tsindex d5551b3..ceb9989 100644--- a/backend/src/services/PlanService.ts+++ b/backend/src/services/PlanService.ts@@ -9,6 +9,7 @@ import { sql } from 'drizzle-orm/sql';import { Plan, NewPlan, planInsertSchema, planUpdateSchema } from '../db/schema/plans';import { Backup } from '../db/schema/backups';import { Restore } from '../db/schema/restores';+import { Device } from '../db/schema/devices';import {BackupPlanArgs,BackupVerifiedResult,@@ -149,11 +150,7 @@ export class PlanService {if (storagePath) {try {const isRemote = !isStorageSource && sourceId !== 'main';- const targetOS = isRemote- ? device?.platform- ? device.platform.toLowerCase()- : undefined- : undefined;+ const targetOS = isRemote && device ? await this.resolvePathPlatform(device) : undefined;theStoragePath = sanitizeStoragePath(storagePath, planStorage.type, targetOS);} catch (error) {@@ -222,6 +219,14 @@ export class PlanService {return createdPlan;}+ /**+ * OS whose path rules apply to a local destination path of a remote source device.+ * Returns undefined to use the server's OS.+ */+ protected async resolvePathPlatform(device: Device): Promise<string | undefined> {+ return device.platform ? device.platform.toLowerCase() : undefined;+ }+/*** Updates a plan's configuration and its underlying schedule.*/diff --git a/backend/src/services/RestoreService.ts b/backend/src/services/RestoreService.tsindex 9f88dc8..f757057 100644--- a/backend/src/services/RestoreService.ts+++ b/backend/src/services/RestoreService.ts@@ -7,6 +7,7 @@ import { StorageStore } from '../stores/StorageStore';import { BaseRestoreManager } from '../managers/BaseRestoreManager';import { RestoreConfig, RestoreOptions } from '../types/restores';import { normalizeStorageName } from '../utils/helpers';+import { PlanFull } from '../types/plans';/*** A class for managing restore operations.@@ -25,6 +26,10 @@ export class RestoreService {return isRemote ? new RemoteStrategy(deviceId) : new LocalStrategy(this.localAgent);}+ getRestoreSources(plan: PlanFull): string[] {+ return plan.sourceConfig?.includes || [];+ }+async getAllRestores() {const restores = await this.restoreStore.getAll();return restores;@@ -110,7 +115,8 @@ export class RestoreService {excludes: restoreConfig.excludes,replicationId: restoreConfig.replicationId,fromStorage: restoreConfig.fromStorage,- sources: plan.sourceConfig?.includes || [],+ sources: this.getRestoreSources(plan),+ extra: restoreConfig.extra,});@@ -173,8 +179,9 @@ export class RestoreService {delete: restoreConfig.delete || false,replicationId: restoreConfig.replicationId,fromStorage: restoreConfig.fromStorage,- sources: plan.sourceConfig.includes || [],+ sources: this.getRestoreSources(plan),performanceSettings,+ extra: restoreConfig.extra,});if (!restoreResult.success) {diff --git a/backend/src/services/events/BackupEventService.ts b/backend/src/services/events/BackupEventService.tsindex 341fb7e..d8889c1 100644--- a/backend/src/services/events/BackupEventService.ts+++ b/backend/src/services/events/BackupEventService.ts@@ -192,7 +192,9 @@ export class BackupEventService {protected async wasFinalized(backupId: string): Promise<boolean> {const backup = await this.backupStore.getById(backupId);return (- !!backup && !backup.inProgress && (backup.status === 'completed' || backup.status === 'failed')+ !!backup &&+ !backup.inProgress &&+ (backup.status === 'completed' || backup.status === 'failed'));}@@ -246,9 +248,18 @@ export class BackupEventService {};const plan = await this.planStore.getById(planId);- if (plan?.method === 'rescue') {- // Since rescue does not do a dry run, we backfill the taskStats with the summary data- // from the completion event, so that it can be used in notifications and elsewhere.+ // A backup that skipped its dry run has no real file counts in taskStats. Backfill them from the+ // completion summary so notifications and history have accurate numbers.+ const existingBackup = await this.backupStore.getById(backupId);+ // If the sourceCongif was actually different from the plan's, record the resolved config+ if (data.resolvedSourceConfig) {+ backupPayload.sourceConfig = {+ ...((existingBackup?.sourceConfig || {}) as object),+ ...data.resolvedSourceConfig,+ } as any;+ }+ const dryRunWasSkipped = (existingBackup?.taskStats as any)?.dry_run_skipped === true;+ if (dryRunWasSkipped) {const shouldBackfillTaskStats = success && summaryData;if (shouldBackfillTaskStats) {backupPayload.taskStats = { ...summaryData, dry_run: false } as any;diff --git a/backend/src/services/events/RestoreEventService.ts b/backend/src/services/events/RestoreEventService.tsindex 9afd3f6..5e58ab9 100644--- a/backend/src/services/events/RestoreEventService.ts+++ b/backend/src/services/events/RestoreEventService.ts@@ -9,6 +9,7 @@ import { SourceTypes } from '../../types/source';import { RestoreCompleteEvent, RestoreErrorEvent, RestoreStartEvent } from '../../types/events';import { BaseRestoreManager } from '../../managers/BaseRestoreManager';import { eventDate } from '../../utils/eventTime';+import { runRestoreCompleteHooks } from './restoreHooks';export class RestoreEventService {constructor(@@ -43,6 +44,7 @@ export class RestoreEventService {includes: config?.includes || [],excludes: config?.excludes || [],delete: config?.delete || false,+ ...(config?.extra ? { extra: config.extra } : {}),},storageId: theBackup.storageId,planId: theBackup.planId,@@ -184,12 +186,18 @@ export class RestoreEventService {progressData = JSON.parse(await readFile(progressFile, 'utf8'));} catch (error: any) {}- await this.restoreStore.update(restoreId, {+ const extra = success ? eventPayload.extra : undefined;+ const config = extra ? (await this.restoreStore.getById(restoreId))?.config : undefined;+ const updated = await this.restoreStore.update(restoreId, {status: success ? 'completed' : 'failed',inProgress: false,ended: eventDate((eventPayload as { occurredAt?: number }).occurredAt),completionStats: progressData?.data,+ ...(config && extra ? { config: { ...config, extra: { ...config.extra, ...extra } } } : {}),});+ if (success && updated) {+ runRestoreCompleteHooks(updated);+ }// if (existsSync(progressFile)) {// await unlink(progressFile);diff --git a/backend/src/services/events/restoreHooks.ts b/backend/src/services/events/restoreHooks.tsnew file mode 100644index 0000000..8d6c2d2--- /dev/null+++ b/backend/src/services/events/restoreHooks.ts@@ -0,0 +1,20 @@+import { Restore } from '../../db/schema/restores';++type RestoreCompleteHook = (restore: Restore) => unknown;++const completeHooks: RestoreCompleteHook[] = [];++export function registerRestoreCompleteHook(fn: RestoreCompleteHook): void {+ completeHooks.push(fn);+}++/** Fire-and-forget: a hook failure never changes the restore result. */+export function runRestoreCompleteHooks(restore: Restore): void {+ for (const hook of completeHooks) {+ Promise.resolve()+ .then(() => hook(restore))+ .catch((error: any) =>+ console.error(`[restore] Completion hook failed for ${restore.id}:`, error?.message || error)+ );+ }+}diff --git a/backend/src/stores/RestoreStore.ts b/backend/src/stores/RestoreStore.tsindex 7a94970..5a3b8f6 100644--- a/backend/src/stores/RestoreStore.ts+++ b/backend/src/stores/RestoreStore.ts@@ -40,12 +40,13 @@ export class RestoreStore {updates.status === 'failed' ||updates.status === 'cancelled';+ // A config-only update keeps the recorded end time.const result = await this.db.update(restores).set({...updates,updatedAt: sql`(unixepoch())`,- ended: ended ? sql`(unixepoch())` : null,+ ...('status' in updates ? { ended: ended ? sql`(unixepoch())` : null } : {}),}).where(eq(identifier === 'backupId' ? restores.backupId : restores.id, id)).returning();diff --git a/backend/src/strategies/system/LocalStrategy.ts b/backend/src/strategies/system/LocalStrategy.tsindex 14a0d34..1bfda49 100644--- a/backend/src/strategies/system/LocalStrategy.ts+++ b/backend/src/strategies/system/LocalStrategy.ts@@ -5,7 +5,7 @@ import { BaseSystemManager } from '../../managers/BaseSystemManager';export class LocalStrategy implements SystemStrategy {constructor(protected localAgent: BaseSystemManager) {}- async getMetrics(): Promise<{ success: boolean; result: Record<string, string | number> }> {+ async getMetrics(payload?: any): Promise<{ success: boolean; result: Record<string, string | number> }> {return await this.localAgent.getMetrics();}diff --git a/backend/src/strategies/system/RemoteStrategy.ts b/backend/src/strategies/system/RemoteStrategy.tsindex fb7896c..cdd9f5b 100644--- a/backend/src/strategies/system/RemoteStrategy.ts+++ b/backend/src/strategies/system/RemoteStrategy.ts@@ -8,7 +8,7 @@ export class RemoteStrategy implements SystemStrategy {this.deviceId = deviceId;}- async getMetrics(): Promise<{ success: boolean; result: Record<string, string | number> }> {+ async getMetrics(payload?: any): Promise<{ success: boolean; result: Record<string, string | number> }> {return await this.publishCommand('GET_METRICS', {});}diff --git a/backend/src/strategies/system/SystemStrategy.ts b/backend/src/strategies/system/SystemStrategy.tsindex b9f43c3..cc3d6d1 100644--- a/backend/src/strategies/system/SystemStrategy.ts+++ b/backend/src/strategies/system/SystemStrategy.ts@@ -2,7 +2,7 @@ import { StrategyMethodTypes } from '../../types/strategy';import { DeviceSettings, DiscoveredFilesystem } from '../../types/devices';export interface SystemStrategy {- getMetrics(): Promise<{ success: boolean; result: any }>;+ getMetrics(payload?: any): Promise<{ success: boolean; result: any }>;getVersions(): Promise<{ success: boolean; result: Record<string, string | number> }>;checkDiskSpace(): Promise<{ success: boolean; result: string | Record<string, any> }>;getBrowsePath(diff --git a/backend/src/types/events.ts b/backend/src/types/events.tsindex 4b4a18d..85551a8 100644--- a/backend/src/types/events.ts+++ b/backend/src/types/events.ts@@ -36,6 +36,7 @@ export interface BackupCompleteEvent {planId: string;success: boolean;summary?: BackupCompletionStats;+ resolvedSourceConfig?: Record<string, unknown>;}// Event emitted when any error occurs.@@ -111,6 +112,7 @@ export interface RestoreCompleteEvent {restoreId: string;planId: string;success: boolean;+ extra?: Record<string, unknown>; // Opaque edition data, merged into restores.config.extra}export interface DownloadStartEvent {diff --git a/backend/src/types/restores.ts b/backend/src/types/restores.tsindex 5a1fde8..f0a9ffd 100644--- a/backend/src/types/restores.ts+++ b/backend/src/types/restores.ts@@ -31,6 +31,7 @@ export interface RestoreConfig {replicationId?: string;sources?: string[];fromStorage?: boolean; // Reads the selected files from the live storage for sync plans+ extra?: Record<string, unknown>; // Opaque edition data, stored in restores.config}export interface RestoreStats {diff --git a/backend/src/utils/executeUserScript.ts b/backend/src/utils/executeUserScript.tsindex 1c954ce..2e68938 100644--- a/backend/src/utils/executeUserScript.ts+++ b/backend/src/utils/executeUserScript.ts@@ -88,7 +88,7 @@ export async function executeUserScript(});}-function isSudoersAuthorizationError(error: unknown): boolean {+export function isSudoersAuthorizationError(error: unknown): boolean {const candidate = error as { message?: string; stderr?: string };const text = `${candidate?.message || ''}\n${candidate?.stderr || ''}`;return (diff --git a/backend/src/utils/restic/restic.ts b/backend/src/utils/restic/restic.tsindex f22776e..f415283 100644--- a/backend/src/utils/restic/restic.ts+++ b/backend/src/utils/restic/restic.ts@@ -36,7 +36,7 @@ export function runResticCommand(onError?: (data: Buffer) => void,onComplete?: (code: number) => void,onProcess?: (process: any) => void,- options?: { timeout?: number; stallTimeout?: number }+ options?: { timeout?: number; stallTimeout?: number; stdout?: NodeJS.WritableStream }): Promise<string> {let lastProgressTime = 0;const THROTTLE_INTERVAL = 2000; // 2 seconds@@ -184,9 +184,15 @@ export function runResticCommand(reject(new Error(errorMsg));});+ // Raw stdout (e.g. `restic dump`) goes to the caller's stream with backpressure.+ if (options?.stdout) {+ resticProcess.stdout?.pipe(options.stdout);+ }+// Handle Restic Output MessagesresticProcess.stdout?.on('data', (data: Buffer) => {lastActivity = Date.now();+ if (options?.stdout) return;const stdoutText = data.toString();if (!isStreaming) {output += stdoutText;diff --git a/frontend/src/@types/plans.ts b/frontend/src/@types/plans.tsindex f4ba2e9..fef775a 100644--- a/frontend/src/@types/plans.ts+++ b/frontend/src/@types/plans.ts@@ -217,3 +217,10 @@ export type PlanChildItem = Pick<Plan, 'id' | 'title' | 'createdAt' | 'isActive'export interface PlanAddRunSettings {runNow: boolean;}++export type PlanBrowseDeviceResolver = (plan?: unknown) => string | undefined;++export type PlanSourceDisplayResolver = (+ plan: unknown,+ options?: { detailed?: boolean }+) => { icon: string; label: string; name?: string; tooltip?: string; online?: boolean } | undefined;diff --git a/frontend/src/components/Plan/Backups/Backups.module.scss b/frontend/src/components/Plan/Backups/Backups.module.scssindex 9bfcdb0..b1d31a4 100644--- a/frontend/src/components/Plan/Backups/Backups.module.scss+++ b/frontend/src/components/Plan/Backups/Backups.module.scss@@ -55,6 +55,14 @@color: var(--content-text-color);}}+ // Slot for an edition-specific row action inside the title cell.+ .rowActions {+ display: inline-flex;+ align-items: center;+ vertical-align: middle;+ margin-left: 6px;+ cursor: default;+ }.planDescription {margin-left: 6px;:global(.icon) {diff --git a/frontend/src/components/Plan/PlanBackups/PlanBackups.tsx b/frontend/src/components/Plan/PlanBackups/PlanBackups.tsxindex 3773717..f64b0e5 100644--- a/frontend/src/components/Plan/PlanBackups/PlanBackups.tsx+++ b/frontend/src/components/Plan/PlanBackups/PlanBackups.tsx@@ -35,8 +35,11 @@ const PlanBackups = ({ plan }: PlanBackupsProps) => {</button></div>{!isSync && historyTab === 'backups' && (- <div className={classes.backupsInfo}>- {snapshotsCount} Active Snapshots <i className="pipe">|</i> {formatBytes(stats.size)}+ <div className={classes.backupsInfo} data-tooltip-id="appTooltip" data-tooltip-content="Backup that can be restored from">+ {snapshotsCount} Active Snapshots <i className="pipe">|</i>{' '}+ <span className={classes.backupsInfoSize} data-tooltip-id="appTooltip" data-tooltip-content="Actual size on disk of all snapshots">+ {formatBytes(stats.size)}+ </span></div>)}</div>diff --git a/frontend/src/components/Plan/PlanItems/PlanItem.tsx b/frontend/src/components/Plan/PlanItems/PlanItem.tsxindex 713cb60..7ce8ea1 100644--- a/frontend/src/components/Plan/PlanItems/PlanItem.tsx+++ b/frontend/src/components/Plan/PlanItems/PlanItem.tsx@@ -1,7 +1,8 @@-import { useState } from 'react';+import { useContext, useState } from 'react';import { toast } from 'react-toastify';import { NavLink } from 'react-router';-import { Plan } from '../../../@types/plans';+import { Plan, PlanSourceDisplayResolver } from '../../../@types/plans';+import { ComponentOverrideContext } from '../../../context/ComponentOverrideContext';import { formatBytes, formatDateTime, getBackupIconName, timeAgo } from '../../../utils/helpers';import Icon from '../../common/Icon/Icon';import StorageIcon from '../../common/Icon/StorageIcon';@@ -38,6 +39,9 @@ const PlanItem = ({ plan, layout = 'list' }: PlanItemProps) => {const { interval = { type: 'daily', time: '10:00AM' }, encryption = false, compression = false } = settings;const [showSettings, setShowSettings] = useState(false);+ const resolveSourceDisplay = useContext(ComponentOverrideContext)['PlanSourceDisplay'] as unknown as PlanSourceDisplayResolver | undefined;+ const sourceDisplay = resolveSourceDisplay?.(plan);+const isStorageSource = plan.sourceType === 'storage';const { data: storageData } = useGetStorages();const sourceStorage = isStorageSource@@ -156,9 +160,14 @@ const PlanItem = ({ plan, layout = 'list' }: PlanItemProps) => {<spandata-tooltip-id="htmlToolTip"data-tooltip-place="top"+ data-tooltip-hidden={!!sourceDisplay}data-tooltip-html={sourceConfig?.includes ? sourceConfig.includes.map((p) => `<div>${p}</div>`).join('') : ''}>- {isStorageSource ? (+ {sourceDisplay ? (+ <>+ <Icon type={sourceDisplay.icon} size={13} /> {sourceDisplay.label}+ </>+ ) : isStorageSource ? (<><StorageIcon type={sourceStorage?.type} size={13} /> {sourceStorage?.name}</>@@ -169,7 +178,7 @@ const PlanItem = ({ plan, layout = 'list' }: PlanItemProps) => {</>))}- <span className={classes.sourceCount}>{sourceConfig.includes.length}</span>+ {!sourceDisplay && <span className={classes.sourceCount}>{sourceConfig.includes.length}</span>}</span>{' '}{'-->'}<PlanStorageInfo replicationSettings={plan.settings.replication} storage={storage} storagePath={plan.storagePath} />diff --git a/frontend/src/components/Plan/PlanStats/PlanStats.module.scss b/frontend/src/components/Plan/PlanStats/PlanStats.module.scssindex 4b706d5..6002578 100644--- a/frontend/src/components/Plan/PlanStats/PlanStats.module.scss+++ b/frontend/src/components/Plan/PlanStats/PlanStats.module.scss@@ -62,6 +62,21 @@display: block;line-height: initial;}+ .sourceIcon {+ position: relative;+ }+ .sourceStatus {+ position: absolute;+ right: -5px;+ bottom: -3px;+ width: 8px;+ height: 8px;+ border-radius: 50%;+ background-color: var(--line-active-color);+ &.online {+ background-color: turquoise;+ }+ }&:nth-child(2) {border: 1px solid var(--line-color);border-radius: 50%;diff --git a/frontend/src/components/Plan/PlanStats/PlanStats.tsx b/frontend/src/components/Plan/PlanStats/PlanStats.tsxindex 2cba3b1..57b9450 100644--- a/frontend/src/components/Plan/PlanStats/PlanStats.tsx+++ b/frontend/src/components/Plan/PlanStats/PlanStats.tsx@@ -1,7 +1,8 @@-import { ReactNode } from 'react';+import { ReactNode, useContext } from 'react';import Icon from '../../common/Icon/Icon';import StorageIcon from '../../common/Icon/StorageIcon';-import { Plan } from '../../../@types/plans';+import { Plan, PlanSourceDisplayResolver } from '../../../@types/plans';+import { ComponentOverrideContext } from '../../../context/ComponentOverrideContext';import { useGetStorages } from '../../../services/storage';import { formatIntervalDisplay, getBackupIconName } from '../../../utils/helpers';import PlanHistory from '../PlanHistory/PlanHistory';@@ -22,6 +23,9 @@ const PlanStats = ({ plan, isSync, lastBackupItem, storageAction }: PlanStatsProconst { interval } = settings;const isStorageSource = plan.sourceType === 'storage';+ const resolveSourceDisplay = useContext(ComponentOverrideContext)['PlanSourceDisplay'] as unknown as PlanSourceDisplayResolver | undefined;+ const sourceDisplay = resolveSourceDisplay?.(plan, { detailed: true });+const { data: storageData } = useGetStorages();const sourceStorage = isStorageSource? ((storageData?.result as { id: string; name: string; type: string }[]) || []).find((s) => s.id === plan.sourceId)@@ -51,9 +55,26 @@ const PlanStats = ({ plan, isSync, lastBackupItem, storageAction }: PlanStatsPro<Icon type={getBackupIconName(plan.method, plan.sourceType)} size={12} /> {isSync ? 'Syncing' : 'Backing Up'}</div><div className={classes.sourceContent}>- <div data-tooltip-id="htmlToolTip" data-tooltip-place="top" data-tooltip-html={sourceTooltipHTML(sourceConfig)}>- {isStorageSource ? <StorageIcon type={sourceStorage?.type} size={18} /> : <Icon type="folders" size={18} />}- <span>{isStorageSource ? sourceName : `${sourceConfig?.includes.length} Sources`}</span>+ <div+ data-tooltip-id="htmlToolTip"+ data-tooltip-place="top"+ {...(sourceDisplay+ ? { 'data-tooltip-html': sourceDisplay.tooltip || sourceDisplay.label }+ : { 'data-tooltip-html': sourceTooltipHTML(sourceConfig) })}+ >+ {sourceDisplay ? (+ <div className={classes.sourceIcon}>+ <Icon type={sourceDisplay.icon} size={18} />+ {sourceDisplay.online !== undefined && (+ <i className={`${classes.sourceStatus} ${sourceDisplay.online ? classes.online : ''}`} />+ )}+ </div>+ ) : isStorageSource ? (+ <StorageIcon type={sourceStorage?.type} size={18} />+ ) : (+ <Icon type="folders" size={18} />+ )}+ <span>{sourceDisplay ? sourceDisplay.name || sourceDisplay.label : isStorageSource ? sourceName : `${sourceConfig?.includes.length} Sources`}</span></div><divdata-tooltip-id="htmlToolTip"diff --git a/frontend/src/components/Plan/Restores/Restores.tsx b/frontend/src/components/Plan/Restores/Restores.tsxindex 67d92a8..4e0b51c 100644--- a/frontend/src/components/Plan/Restores/Restores.tsx+++ b/frontend/src/components/Plan/Restores/Restores.tsx@@ -10,6 +10,10 @@ import StatusLabel from '../../common/StatusLabel/StatusLabel';import { useDeleteRestore } from '../../../services/restores';import BackupEvents from '../BackupEvents/BackupEvents';import RestoreChangeViewer from '../../Restore/RestoreChangeViewer/RestoreChangeViewer';+import { useComponentOverride } from '../../../context/ComponentOverrideContext';++const DefaultRowActions = () => null;+const DefaultRowMenuActions = () => null;const Restores = ({planId,@@ -28,6 +32,8 @@ const Restores = ({const [previewRestore, setPreviewRestore] = useState<false | RestoreSlim>(false);const [showDeleteModal, setShowDeleteModal] = useState<RestoreSlim | false>(false);const [showRestoreEvents, setShowRestoreEvents] = useState<false | string>(false);+ const RowActions = useComponentOverride('RestoreRowActions', DefaultRowActions);+ const RowMenuActions = useComponentOverride('RestoreRowMenuActions', DefaultRowMenuActions);const queryClient = useQueryClient();const deleteRestoreMutation = useDeleteRestore();@@ -71,6 +77,9 @@ const Restores = ({><div className={classes.restoreTitle} onClick={() => !isSync && setShowRestoreEvents(id)}><Icon type={isSync ? 'sync' : 'box'} size={14} /> {isSync ? 'sync' : 'backup'}-{backupId}+ <span className={classes.rowActions} onClick={(e) => e.stopPropagation()}>+ <RowActions restore={restore} planId={planId} method={method} />+ </span></div><divclassName={classes.status}@@ -95,6 +104,7 @@ const Restores = ({</div>{showSnapOptions === id && (<div className={classes.settings}>+ <RowMenuActions restore={restore} planId={planId} method={method} closeMenu={() => setShowSnapOptions(false)} /><buttononClick={() => {setPreviewRestore(restore);diff --git a/frontend/src/components/Plan/SnapshotViewer/SnapshotViewer.tsx b/frontend/src/components/Plan/SnapshotViewer/SnapshotViewer.tsxindex 4b21b7e..1061625 100644--- a/frontend/src/components/Plan/SnapshotViewer/SnapshotViewer.tsx+++ b/frontend/src/components/Plan/SnapshotViewer/SnapshotViewer.tsx@@ -34,6 +34,8 @@ interface SnapshotViewerProps {isExternalLoading?: boolean;/** Render additional action buttons per file row (e.g. View, Download, Compare in Pro). */renderFileActions?: (file: FileItem, meta: { fileExtension: string; isDirectory: boolean }) => ReactNode;+ /** Hides the per-file Restore action. */+ hideRestore?: boolean;/** Extra elements rendered at the end (e.g. BackupFileLoader modal in Pro). */children?: ReactNode;primaryStorage?: { id: string; type: string; name: string };@@ -57,6 +59,7 @@ const SnapshotViewer = ({toolbarRightContent,isExternalLoading,renderFileActions,+ hideRestore = false,children,primaryStorage,onStorageChange,@@ -212,11 +215,12 @@ const SnapshotViewer = ({onDirectoryClick={handleDirectoryClick}onRestore={(file) => setShowRestoreModal(file)}renderFileActions={renderFileActions}+ hideRestore={hideRestore}showUpgradeModal={() => setShowUpgrade(true)}/>);},- [currentDirectoryFiles, isSync, gridColumns, handleGoUp, handleDirectoryClick, renderFileActions],+ [currentDirectoryFiles, isSync, gridColumns, handleGoUp, handleDirectoryClick, renderFileActions, hideRestore],);// Error statediff --git a/frontend/src/components/Plan/SnapshotViewer/SnapshotViewerFile.tsx b/frontend/src/components/Plan/SnapshotViewer/SnapshotViewerFile.tsxindex 4d8d48a..a3ac849 100644--- a/frontend/src/components/Plan/SnapshotViewer/SnapshotViewerFile.tsx+++ b/frontend/src/components/Plan/SnapshotViewer/SnapshotViewerFile.tsx@@ -14,6 +14,7 @@ interface SnapshotViewerFileProps {onDirectoryClick: (path: string) => void;onRestore: (file: FileItem) => void;renderFileActions?: (file: FileItem, meta: { fileExtension: string; isDirectory: boolean }) => ReactNode;+ hideRestore?: boolean;showUpgradeModal?: () => void;}@@ -26,6 +27,7 @@ const SnapshotViewerFile = ({onDirectoryClick,onRestore,renderFileActions,+ hideRestore,showUpgradeModal,}: SnapshotViewerFileProps) => {if (!file) return null;@@ -94,18 +96,20 @@ const SnapshotViewerFile = ({<Icon type={'download'} size={16} /></button>)}- <button- data-tooltip-id="htmlToolTip"- data-tooltip-place="top"- data-tooltip-delay-show={500}- data-tooltip-html="Restore"- onClick={(e) => {- e.stopPropagation();- onRestore(typedFile);- }}- >- <Icon type={'restore'} size={16} />- </button>+ {!hideRestore && (+ <button+ data-tooltip-id="htmlToolTip"+ data-tooltip-place="top"+ data-tooltip-delay-show={500}+ data-tooltip-html="Restore"+ onClick={(e) => {+ e.stopPropagation();+ onRestore(typedFile);+ }}+ >+ <Icon type={'restore'} size={16} />+ </button>+ )}</div>)}</div>diff --git a/frontend/src/components/common/Icon/Icon.tsx b/frontend/src/components/common/Icon/Icon.tsxindex d0c3e7b..6992f5c 100644--- a/frontend/src/components/common/Icon/Icon.tsx+++ b/frontend/src/components/common/Icon/Icon.tsx@@ -362,6 +362,23 @@ const Icon = ({ type, color = 'currentColor', size = 16, title = '', classes = '/></IconWrapper>)}+ {type === 'container' && (+ <IconWrapper size={size} viewBox="0 0 24 24">+ <g fill="none" stroke={color} strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.8}>+ <rect x="2" y="5" width="20" height="14" rx="2" />+ <path d="M7 8.5v7m5-7v7m5-7v7" />+ </g>+ </IconWrapper>+ )}+ {type === 'vm-backup' && (+ <IconWrapper size={size} viewBox="0 0 27.59 22.69">+ <path+ d="M22,13.65A6,6,0,0,0,10,14a1,1,0,0,1-1,1c-3.62,0-5,2.53-5,4a3.93,3.93,0,0,0,.88,2.59C5.51,22.32,6.71,23,9,23h5.5v2H9c-2.71,0-4.51-.82-5.63-2.09A5.88,5.88,0,0,1,2,19a6.35,6.35,0,0,1,6.06-5.95A8,8,0,0,1,24,13.64a3.49,3.49,0,0,0-2,0m7.19,4.23-6.11-2.72a.66.66,0,0,0-.55,0L16.4,17.88l0,0-.06,0,0,0a.86.86,0,0,0-.13.14l0,0a.54.54,0,0,0-.05.11.14.14,0,0,0,0,.06.57.57,0,0,0,0,.18v6.79a.7.7,0,0,0,.4.63l6.12,2.71a.66.66,0,0,0,.27.06.67.67,0,0,0,.28-.06h0l6.11-2.71a.69.69,0,0,0,.41-.63V18.5a.68.68,0,0,0-.41-.62m-6.39-1.35,4.45,2-4.45,2-.88-.39L18.35,18.5Zm-5.43,8.32v-5.3l4.75,2.11V27ZM23.47,27V21.66l4.76-2.11v5.3Z"+ transform="translate(-2 -6)"+ fill={color}+ />+ </IconWrapper>+ )}{type === 'database' && (<IconWrapper size={size} viewBox="0 0 24 24"><g fill="none" stroke={color} strokeWidth={1.5}>diff --git a/frontend/src/routes/DeviceSingle/DeviceSingle.tsx b/frontend/src/routes/DeviceSingle/DeviceSingle.tsxindex f0bd761..de4f3bb 100644--- a/frontend/src/routes/DeviceSingle/DeviceSingle.tsx+++ b/frontend/src/routes/DeviceSingle/DeviceSingle.tsx@@ -1,5 +1,5 @@import { useParams } from 'react-router';-import { useState } from 'react';+import { useContext, useState } from 'react';import Icon from '../../components/common/Icon/Icon';import PageHeader from '../../components/common/PageHeader/PageHeader';import { useGetDevice, useGetSystemMetrics } from '../../services/devices';@@ -9,12 +9,14 @@ import classes from './DeviceSingle.module.scss';import NotFound from '../../components/common/NotFound/NotFound';import DeviceBackups from '../../components/Device/DeviceBackups/DeviceBackups';import { DevicePlan, DeviceStorage } from '../../@types/devices';+import { ComponentOverrideContext } from '../../context/ComponentOverrideContext';const DeviceSingle = () => {const { id } = useParams();const [showEditModal, setShowEditModal] = useState(false);const { data, isLoading, error: DeviceError } = useGetDevice(id as string);const { data: metricsData } = useGetSystemMetrics(id as string);+ const DeviceSections = useContext(ComponentOverrideContext)['DeviceSections'];console.log('DeviceError :', DeviceError, (DeviceError as Error & { status?: number })?.status);@@ -74,6 +76,7 @@ const DeviceSingle = () => {) : (<><DeviceBackups plans={devicePlans} storages={deviceStorages} />+ {DeviceSections && <DeviceSections device={device} metrics={metrics} />}{metrics?.system && <DeviceInfo metrics={metrics} isRefetching={false} />}</>)}diff --git a/frontend/src/routes/PlanSingle/PlanSingle.tsx b/frontend/src/routes/PlanSingle/PlanSingle.tsxindex 0e5524c..3c8c0d1 100644--- a/frontend/src/routes/PlanSingle/PlanSingle.tsx+++ b/frontend/src/routes/PlanSingle/PlanSingle.tsx@@ -19,6 +19,8 @@ import PlanRepair from '../../components/Plan/PlanRepair/PlanRepair';import { PlanVerifiedResult } from '../..';import { getBackupIconName } from '../../utils';+const DefaultPlanMenuActions = () => null;+const PlanSingle = () => {const [showMoreOptions, setShowMoreOptions] = useState(false);const [showIntegrityModal, setShowIntegrityModal] = useState(false);@@ -26,6 +28,7 @@ const PlanSingle = () => {const { id } = useParams();const EditPlanModal = useComponentOverride('EditPlan', EditPlan);+ const PlanMenuActions = useComponentOverride('PlanMenuActions', DefaultPlanMenuActions);const [searchParams] = useSearchParams();const isBackupPending = searchParams.get('pendingbackup') === '1';@@ -137,6 +140,7 @@ const PlanSingle = () => {<Icon size={14} type="unlock" /> Unlock</li>)}+ <PlanMenuActions plan={plan} closeMenu={() => setShowMoreOptions(false)} /><liclassName={classes.actionBtn}onClick={() => {diff --git a/frontend/src/utils/helpers.ts b/frontend/src/utils/helpers.tsindex 3b9a3f8..3fc4e0d 100644--- a/frontend/src/utils/helpers.ts+++ b/frontend/src/utils/helpers.ts@@ -578,5 +578,8 @@ export const getBackupIconName = (method: string, sourceType?: string): string =if (method === 'rescue') {return 'rescue';}+ if (method === 'vm') {+ return 'vm-backup';+ }return 'backup';};diff --git a/frontend/src/utils/progressHelpers.ts b/frontend/src/utils/progressHelpers.tsindex 7e8571b..eee5d33 100644--- a/frontend/src/utils/progressHelpers.ts+++ b/frontend/src/utils/progressHelpers.ts@@ -1,5 +1,30 @@import { BackupProgressData } from '../@types/backups';+const registeredBackupMessages: Record<string, string> = {};+const registeredRestoreMessages: Record<string, string> = {};+const registeredPhaseNames: Record<string, string> = {};++export const registerBackupActionMessages = (messages: Record<string, string>): void => {+ Object.assign(registeredBackupMessages, messages);+};++export const registerRestoreActionMessages = (messages: Record<string, string>): void => {+ Object.assign(registeredRestoreMessages, messages);+};++export const registerPhaseDisplayNames = (names: Record<string, string>): void => {+ Object.assign(registeredPhaseNames, names);+};++// Turn an unmapped action code (e.g. SOME_ACTION_START) into readable text+const humanizeAction = (action: string): string =>+ action+ .toLowerCase()+ .split('_')+ .filter(Boolean)+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))+ .join(' ') || action;+export function generateBackupProgressMessage(progressData: BackupProgressData | null): string {if (!progressData?.events?.length) {return 'Initializing...';@@ -29,7 +54,7 @@ export function generateBackupProgressMessage(progressData: BackupProgressData |finished: 'Complete',};- const phaseDisplay = phaseDisplayNames[phase] || phase;+ const phaseDisplay = phaseDisplayNames[phase] || registeredPhaseNames[phase] || phase;const actionDisplay = getBackupEventActionMessage(action);if (phase === 'finished') {@@ -197,7 +222,7 @@ export const getBackupEventActionMessage = (action: string, storageName?: stringreturn replicationMessagesWithStorage[action](storageName);}- return staticMessages[action] || action;+ return staticMessages[action] || registeredBackupMessages[action] || humanizeAction(action);};export function generateRestoreProgressMessage(progressData: BackupProgressData | null): string {@@ -229,7 +254,7 @@ export function generateRestoreProgressMessage(progressData: BackupProgressDatafinished: 'Complete',};- const phaseDisplay = phaseDisplayNames[phase] || phase;+ const phaseDisplay = phaseDisplayNames[phase] || registeredPhaseNames[phase] || phase;const actionDisplay = getRestoreEventActionMessage(action);if (phase === 'finished') {@@ -287,7 +312,7 @@ export const getRestoreEventActionMessage = (action: string): string => {TASK_CANCELLED: 'Restore Cancelled by User.',FAILED_PERMANENTLY: 'Failed Permanently',};- return staticMessages[action] || action;+ return staticMessages[action] || registeredRestoreMessages[action] || humanizeAction(action);};export function extractResticData(progressData: BackupProgressData | null) {