A modern, self-hosted backup solution for secure, encrypted backups across local and cloud storage.
chore: facilitate Database backup plans feature for pluton biz
towfiqi83c235513b70
diff --git a/backend/__tests__/managers/BaseSnapshotManager.test.ts b/backend/__tests__/managers/BaseSnapshotManager.test.tsindex 23f0643..c2d0f20 100644--- a/backend/__tests__/managers/BaseSnapshotManager.test.ts+++ b/backend/__tests__/managers/BaseSnapshotManager.test.ts@@ -16,6 +16,7 @@ jest.mock('../../src/managers/handlers/DownloadHandler', () => {jest.mock('../../src/utils/restic/restic', () => ({runResticCommand: jest.fn(),getSnapshotByTag: jest.fn(),+ getSnapshotsByTag: jest.fn(),getBackupPlanStats: jest.fn(),}));@@ -41,6 +42,7 @@ jest.mock('fs/promises', () => ({import {runResticCommand,getSnapshotByTag,+ getSnapshotsByTag,getBackupPlanStats,} from '../../src/utils/restic/restic';import { generateResticRepoPath, resticPathToWindows } from '../../src/utils/restic/helpers';@@ -145,10 +147,7 @@ describe('BaseSnapshotManager', () => {};it('should forget snapshot and return updated stats', async () => {- (getSnapshotByTag as jest.Mock).mockResolvedValue({- success: true,- result: { id: 'snap-abc' },- });+ (getSnapshotsByTag as jest.Mock).mockResolvedValue([{ id: 'snap-abc' }]);(runResticCommand as jest.Mock).mockResolvedValue('forget-ok');(getBackupPlanStats as jest.Mock).mockResolvedValue({total_size: 123,@@ -171,11 +170,23 @@ describe('BaseSnapshotManager', () => {});});+ it('should forget all snapshots of the backup in one command', async () => {+ (getSnapshotsByTag as jest.Mock).mockResolvedValue([{ id: 'snap-a' }, { id: 'snap-b' }]);+ (runResticCommand as jest.Mock).mockResolvedValue('forget-ok');+ (getBackupPlanStats as jest.Mock).mockResolvedValue(null);++ const mgr = new BaseSnapshotManager();+ await mgr.removeSnapshot('plan-1', 'backup-1', options);++ expect(runResticCommand).toHaveBeenCalledTimes(1);+ expect(runResticCommand).toHaveBeenCalledWith(+ ['-r', 'mock-repo-path', 'forget', 'snap-a', 'snap-b', '--json'],+ { RESTIC_PASSWORD: 'mySecretKey' }+ );+ });+it('should return early when snapshot not found', async () => {- (getSnapshotByTag as jest.Mock).mockResolvedValue({- success: false,- result: 'Snapshot Not Found',- });+ (getSnapshotsByTag as jest.Mock).mockResolvedValue([]);const mgr = new BaseSnapshotManager();const out = await mgr.removeSnapshot('plan-1', 'backup-1', options);@@ -188,6 +199,20 @@ describe('BaseSnapshotManager', () => {stats: { primary: null, mirrors: {} },});});++ it('should skip the repo when the snapshot lookup fails', async () => {+ (getSnapshotsByTag as jest.Mock).mockRejectedValue(new Error('repo locked'));++ const mgr = new BaseSnapshotManager();+ const out = await mgr.removeSnapshot('plan-1', 'backup-1', options);++ expect(runResticCommand).not.toHaveBeenCalled();+ expect(out).toEqual({+ success: true,+ result: {},+ stats: { primary: null, mirrors: {} },+ });+ });});describe('getSnapshotFiles', () => {diff --git a/backend/__tests__/managers/handlers/BackupHandler.test.ts b/backend/__tests__/managers/handlers/BackupHandler.test.tsindex dde0f0d..144d59b 100644--- a/backend/__tests__/managers/handlers/BackupHandler.test.ts+++ b/backend/__tests__/managers/handlers/BackupHandler.test.ts@@ -340,12 +340,46 @@ describe('BackupHandler', () => {);});+ it('should permanently fail (no retry) when the error is flagged retryable:false', async () => {+ mockRunResticCommand.mockImplementation((args: string[]) => {+ const isBackup = args[0] === 'backup' && !args.includes('--dry-run');+ if (isBackup) {+ return Promise.reject(+ Object.assign(new Error('server version not supported'), { retryable: false })+ );+ }+ return Promise.resolve('{"message_type":"summary"}');+ });++ await expect(+ handler.execute('plan-1', 'backup-1', baseOptions, { attempts: 0, maxAttempts: 5 })+ ).rejects.toMatchObject({ retryable: false });++ expect(mockMarkCompleted).toHaveBeenCalledWith(+ 'plan-1',+ 'backup-1',+ false,+ expect.stringContaining('server version not supported'),+ true+ );+ expect(mockUpdateAction).not.toHaveBeenCalledWith(+ 'plan-1',+ 'backup-1',+ 'retry',+ expect.stringContaining('BACKUP_RETRY'),+ false,+ undefined+ );+ });+it('should schedule a retry when backup exits with a retryable code', async () => {// The actual backup rejects with lock-failed (11) - transient, should retry.mockRunResticCommand.mockImplementation((args: string[]) => {const isBackup = args[0] === 'backup' && !args.includes('--dry-run');if (isBackup) {- return Promise.reject(Object.assign(new Error('unable to lock repository'), { code: 11 }));+ return Promise.reject(+ Object.assign(new Error('unable to lock repository'), { code: 11 })+ );}return Promise.resolve('{"message_type":"summary"}');});@@ -776,7 +810,7 @@ describe('BackupHandler', () => {// statfs reports free bytes as bavail * bsize; use bsize = 1 so bavail is the byte count.const statfsWithAvailable = (available: number) =>- ({ bsize: 1, bavail: available, blocks: 10 * GiB, bfree: available } as any);+ ({ bsize: 1, bavail: available, blocks: 10 * GiB, bfree: available }) as any;let statfsSpy: jest.SpyInstance;@@ -823,9 +857,9 @@ describe('BackupHandler', () => {statfsSpy.mockResolvedValue(statfsWithAvailable(100 * 1024 * 1024));const resticArgsAndEnv = handler.createResticBackupArgs('plan-1', localOptions as any);- await expect(- handler.canRun(localOptions, resticArgsAndEnv, dryRun)- ).rejects.toMatchObject({ retryable: false });+ await expect(handler.canRun(localOptions, resticArgsAndEnv, dryRun)).rejects.toMatchObject({+ retryable: false,+ });});it('passes when space is sufficient', async () => {@@ -986,6 +1020,17 @@ describe('BackupHandler', () => {expect(mockTrackProcess).toHaveBeenCalledWith('backup-backup-1', mockProcess);});+ it('passes the timeout of the run config to restic', async () => {+ const resticArgsAndEnv = handler.createResticBackupArgs('plan-1', baseOptions as any);+ await handler['executeBackupPhase']('plan-1', 'backup-1', baseOptions, resticArgsAndEnv, {+ timeout: 60_000,+ });++ expect(mockRunResticCommand.mock.calls.at(-1)?.[6]).toEqual(+ expect.objectContaining({ stallTimeout: expect.any(Number), timeout: 60_000 })+ );+ });+it('should use encryption key when encryption is enabled', async () => {const encryptedOptions = {...baseOptions,diff --git a/backend/__tests__/managers/handlers/RestoreHandler.test.ts b/backend/__tests__/managers/handlers/RestoreHandler.test.tsindex 0284651..34fa174 100644--- a/backend/__tests__/managers/handlers/RestoreHandler.test.ts+++ b/backend/__tests__/managers/handlers/RestoreHandler.test.ts@@ -286,7 +286,7 @@ describe('RestoreHandler', () => {});it('should handle cancellation during execution', async () => {- handler['cancelledRestores'].add('plan-1');+ handler['cancelledRestores'].add('restore-1');mockGetSnapshotByTag.mockResolvedValueOnce({success: true,@@ -316,9 +316,41 @@ describe('RestoreHandler', () => {});expect(result).toBe('');- handler['cancelledRestores'].delete('plan-1');+ handler['cancelledRestores'].delete('restore-1');}, 15000);+ it('should run a new restore of a plan after a cancel of a restore that was not running', async () => {+ await handler.cancel('plan-1', 'restore-old');++ mockRunResticCommand+ .mockResolvedValueOnce(+ JSON.stringify({+ message_type: 'summary',+ total_files: 10,+ files_restored: 10,+ total_bytes: 1000,+ bytes_restored: 1000,+ })+ )+ .mockResolvedValueOnce('restore complete');+ setTimeout(() => {+ emitter.emit('restoreCreated', { backupId: 'backup-1', restoreId: 'restore-1' });+ }, 10);++ await handler.execute('backup-1', 'restore-1', baseOptions, { attempts: 0, maxAttempts: 3 });++ expect(mockUpdateAction).toHaveBeenCalledWith(+ 'plan-1',+ 'restore-1',+ 'restore',+ 'RESTORE_OPERATION_START',+ false,+ undefined+ );+ expect(mockMarkCompleted).toHaveBeenCalledWith('plan-1', 'restore-1', true);+ handler['cancelledRestores'].delete('restore-old');+ });+it('should emit error event and schedule retry on non-final failure', async () => {const errorListener = jest.fn();emitter.on('restore_error', errorListener);@@ -386,6 +418,37 @@ describe('RestoreHandler', () => {);});+ it('should permanently fail (no retry) when the error is flagged retryable:false', async () => {+ emitter.on('restoreCreated', () => {});+ setTimeout(() => {+ emitter.emit('restoreCreated', { backupId: 'backup-1', restoreId: 'restore-1' });+ }, 10);++ mockGetSnapshotByTag.mockRejectedValueOnce(+ Object.assign(new Error('Target version too old'), { retryable: false })+ );++ await expect(+ handler.execute('backup-1', 'restore-1', baseOptions, { attempts: 0, maxAttempts: 3 })+ ).rejects.toMatchObject({ retryable: false });++ expect(mockMarkCompleted).toHaveBeenCalledWith(+ 'plan-1',+ 'restore-1',+ false,+ 'Target version too old',+ true+ );+ expect(mockUpdateAction).not.toHaveBeenCalledWith(+ 'plan-1',+ 'restore-1',+ 'retry',+ expect.stringContaining('RESTORE_RETRY'),+ false,+ undefined+ );+ });+it('should timeout if restoreCreated event not received', async () => {// This test validates the private waitForRestoreCreation method times outjest.useFakeTimers();@@ -467,7 +530,7 @@ describe('RestoreHandler', () => {// statfs reports free bytes as bavail * bsize; use bsize = 1 so bavail is the byte count.const statfsWithAvailable = (available: number) =>- ({ bsize: 1, bavail: available, blocks: 10 * GiB, bfree: available } as any);+ ({ bsize: 1, bavail: available, blocks: 10 * GiB, bfree: available }) as any;const stats = { total_bytes: 500 * 1024 * 1024, bytes_restored: 500 * 1024 * 1024 };diff --git a/backend/__tests__/utils/restic/restic.test.ts b/backend/__tests__/utils/restic/restic.test.tsindex fbf087c..632375e 100644--- a/backend/__tests__/utils/restic/restic.test.ts+++ b/backend/__tests__/utils/restic/restic.test.ts@@ -29,6 +29,7 @@ import {runResticCommand,getBackupPlanStats,getSnapshotByTag,+ getSnapshotsByTag,handleResticCheckResult,} from '../../../src/utils/restic/restic';import { getBinaryPath } from '../../../src/utils/binaryPathResolver';@@ -561,6 +562,29 @@ describe('runResticCommand', () => {expect(mockKillProcessTree).not.toHaveBeenCalled();});});++ describe('timeout', () => {+ beforeEach(() => jest.useFakeTimers());+ afterEach(() => jest.useRealTimers());++ it('kills the process tree with SIGKILL and rejects with timedOut', async () => {+ const promise = runResticCommand(+ ['backup', '/test'],+ undefined,+ jest.fn(),+ undefined,+ undefined,+ undefined,+ { timeout: 5_000 }+ );+ const settled = expect(promise).rejects.toMatchObject({ timedOut: true });++ await jest.advanceTimersByTimeAsync(5_000);++ await settled;+ expect(mockKillProcessTree).toHaveBeenCalledWith(mockProcess, 'SIGKILL');+ });+ });});describe('getBackupPlanStats', () => {@@ -1108,6 +1132,47 @@ describe('getSnapshotByTag', () => {expect(mockGenerateResticRepoPath).toHaveBeenCalledWith('custom-storage', 'custom-path');});++ describe('getSnapshotsByTag', () => {+ const mockOutput = (output: string, code = 0) => {+ const captured: { args?: string[] } = {};+ mockSpawn.mockImplementation((binary, args) => {+ captured.args = args as string[];+ const process = new EventEmitter() as any;+ process.stdout = new EventEmitter();+ process.stderr = new EventEmitter();+ process.kill = jest.fn();+ setImmediate(() => {+ if (code === 0) process.stdout.emit('data', Buffer.from(output));+ else process.stderr.emit('data', Buffer.from(output));+ process.emit('close', code);+ });+ return process;+ });+ return captured;+ };+ const opts = { storagePath: 'path', storageName: 'storage', encryption: false };++ it('returns all snapshots with an id and passes the tag list as is', async () => {+ const captured = mockOutput(JSON.stringify([{ id: 'a' }, { tags: ['x'] }, { id: 'b' }]));++ const result = await getSnapshotsByTag('backup-1,db-main', opts);++ expect(result.map(s => s.id)).toEqual(['a', 'b']);+ const tagIdx = captured.args!.indexOf('--tag');+ expect(captured.args![tagIdx + 1]).toBe('backup-1,db-main');+ });++ it('returns an empty array when no snapshot matches', async () => {+ mockOutput('[]');+ await expect(getSnapshotsByTag('tag', opts)).resolves.toEqual([]);+ });++ it('rejects when restic fails', async () => {+ mockOutput('repository not found', 1);+ await expect(getSnapshotsByTag('tag', opts)).rejects.toThrow();+ });+ });});describe('handleResticCheckResult', () => {diff --git a/backend/src/managers/BaseSnapshotManager.ts b/backend/src/managers/BaseSnapshotManager.tsindex ea94d67..4520cc9 100644--- a/backend/src/managers/BaseSnapshotManager.ts+++ b/backend/src/managers/BaseSnapshotManager.ts@@ -1,6 +1,11 @@import { EventEmitter } from 'events';import { readFile, writeFile } from 'fs/promises';-import { getBackupPlanStats, getSnapshotByTag, runResticCommand } from '../utils/restic/restic';+import {+ getBackupPlanStats,+ getSnapshotByTag,+ getSnapshotsByTag,+ runResticCommand,+} from '../utils/restic/restic';import { generateResticRepoPath, resticPathToWindows } from '../utils/restic/helpers';import { DownloadHandler } from './handlers/DownloadHandler';import { configService } from '../services/ConfigService';@@ -118,19 +123,22 @@ export class BaseSnapshotManager extends EventEmitter {}for (const repo of reposToRemove) {const repoPath = generateResticRepoPath(repo.name, repo.path || '');- const { success, result } = await getSnapshotByTag('backup-' + backupId, {+ const snapshots = await getSnapshotsByTag('backup-' + backupId, {storageName: repo.name,storagePath: repo.path,encryption,- });- if (!success || typeof result === 'string') {+ }).catch(() => []);+ if (!snapshots.length) {continue;}- const snapshotId = result.id;-- const output = await runResticCommand(['-r', repoPath, 'forget', snapshotId, '--json'], {- RESTIC_PASSWORD: repoPassword,- });+ const snapshotIds = snapshots.map(snap => snap.id);++ const output = await runResticCommand(+ ['-r', repoPath, 'forget', ...snapshotIds, '--json'],+ {+ RESTIC_PASSWORD: repoPassword,+ }+ );removalOutput[repo.id] = output;const repoStats = await getBackupPlanStats(planId, repo.name, repo.path, encryption);if (repo.id === 'primary') {diff --git a/backend/src/managers/handlers/BackupHandler.ts b/backend/src/managers/handlers/BackupHandler.tsindex 235d2e1..a61306f 100644--- a/backend/src/managers/handlers/BackupHandler.ts+++ b/backend/src/managers/handlers/BackupHandler.ts@@ -163,7 +163,8 @@ export class BackupHandler {// If restic fails with code 10 or 12, retry cannot fix them, so fail immediatelyconst resticExitCode = (error as ResticCommandError)?.code;const classification = classifyResticExitCode(resticExitCode);- const isNonRetryable = resticExitCode !== undefined && !classification.retryable;+ const isNonRetryable =+ (resticExitCode !== undefined && !classification.retryable) || error?.retryable === false;const attemptsExhausted = retryInfo.attempts + 1 >= retryInfo.maxAttempts;const permanentlyFailed = attemptsExhausted || isNonRetryable;@@ -332,7 +333,7 @@ export class BackupHandler {handlers.onError,handlers.onComplete,process => processManager.trackProcess('backup-' + backupId, process),- { stallTimeout: RESTIC_STALL_TIMEOUT_MS }+ { stallTimeout: RESTIC_STALL_TIMEOUT_MS, timeout: runConfig?.timeout });if (!this.cancelledBackups.has(planId + backupId)) {// Exit code 3: snapshot created with warnings. Log this as a warningdiff --git a/backend/src/managers/handlers/RestoreHandler.ts b/backend/src/managers/handlers/RestoreHandler.tsindex 0bdbed0..147384d 100644--- a/backend/src/managers/handlers/RestoreHandler.ts+++ b/backend/src/managers/handlers/RestoreHandler.ts@@ -101,13 +101,13 @@ export class RestoreHandler {try {// --- 1. PRE-RESTORE PHASE ---const snapshot = await this.preRestorePhase(planId, backupId, restoreId, options);- if (this.cancelledRestores.has(planId)) {+ if (this.cancelledRestores.has(restoreId)) {throw new Error('RESTORE_CANCELLED: Restore was cancelled');}// --- 2. RESTORE PHASE ---const result = await this.executeRestorePhase(planId, backupId, restoreId, snapshot, options);- if (this.cancelledRestores.has(planId)) {+ if (this.cancelledRestores.has(restoreId)) {throw new Error('RESTORE_CANCELLED: Restore was cancelled');}@@ -129,7 +129,8 @@ export class RestoreHandler {}// --- 4. CENTRALIZED ERROR HANDLING ---- const permanentlyFailed = retryInfo.attempts + 1 >= retryInfo.maxAttempts;+ const isNonRetryable = error?.retryable === false;+ const permanentlyFailed = retryInfo.attempts + 1 >= retryInfo.maxAttempts || isNonRetryable;await this.progressManager.markCompleted(planId,@@ -166,10 +167,12 @@ export class RestoreHandler {await this.afterRestore(planId, restoreId, options);// Re-throw the error for the JobProcessor to handle retries.- throw new Error(errorMessage);+ const rethrown: Error & { retryable?: boolean } = new Error(errorMessage);+ rethrown.retryable = !isNonRetryable;+ throw rethrown;} finally {this.runningRestores.delete(planId);- this.cancelledRestores.delete(planId);+ this.cancelledRestores.delete(restoreId);}}@@ -700,7 +703,7 @@ export class RestoreHandler {}async cancel(planId: string, restoreId: string) {- this.cancelledRestores.add(planId);+ this.cancelledRestores.add(restoreId);await this.progressManager.markCompleted(planId,restoreId,diff --git a/backend/src/types/backups.ts b/backend/src/types/backups.tsindex 2382e68..ef04d1a 100644--- a/backend/src/types/backups.ts+++ b/backend/src/types/backups.ts@@ -100,4 +100,5 @@ export type BackupRunConfig = {skipDryRun?: boolean;skipPrune?: boolean;ignoreErrors?: boolean;+ timeout?: number;};diff --git a/backend/src/utils/restic/restic.ts b/backend/src/utils/restic/restic.tsindex f415283..66caa0a 100644--- a/backend/src/utils/restic/restic.ts+++ b/backend/src/utils/restic/restic.ts@@ -130,12 +130,8 @@ export function runResticCommand(timeoutHandle = setTimeout(() => {timedOut = true;// SIGKILL rather than SIGTERM: a wedged rclone transport may not- // respond to a graceful signal.- try {- resticProcess.kill('SIGKILL');- } catch {- // Process may have already exited.- }+ // respond to a graceful signal. The tree: a stdin command of restic also stops.+ killProcessTree(resticProcess as KillableProcess, 'SIGKILL');const timeoutError: ResticCommandError = new Error(`Restic command timed out after ${timeoutMs}ms`);@@ -367,34 +363,32 @@ export async function getBackupPlanStats(}}-export async function getSnapshotByTag(+/**+ * Lists all snapshots with the tag. A comma-separated tag ('a,b') matches+ * snapshots that have all of the tags. Throws when restic fails.+ */+export async function getSnapshotsByTag(tag: string,options: { storagePath: string; storageName: string; encryption: boolean }-): Promise<{ success: boolean; result: ResticSnapshot | string }> {+): Promise<ResticSnapshot[]> {const { storageName, storagePath, encryption } = options;const repoPassword = encryption ? configService.config.ENCRYPTION_KEY : '';const repoPath = generateResticRepoPath(storageName, storagePath);+ const snapRes = await runResticCommand(['-r', repoPath, 'snapshots', '--tag', tag, '--json'], {+ RESTIC_PASSWORD: repoPassword,+ });+ const snapResArr = snapRes ? JSON.parse(snapRes) : [];+ return Array.isArray(snapResArr) ? snapResArr.filter(snap => snap?.id) : [];+}++export async function getSnapshotByTag(+ tag: string,+ options: { storagePath: string; storageName: string; encryption: boolean }+): Promise<{ success: boolean; result: ResticSnapshot | string }> {const failedObj = { success: false, result: 'Snapshot Not Found' };try {- const snapshotResticArgs = ['-r', repoPath, 'snapshots', '--tag', tag, '--json'];- const snapRes = await runResticCommand(snapshotResticArgs, {- RESTIC_PASSWORD: repoPassword,- });-- if (snapRes) {- const snapResArr = JSON.parse(snapRes);- if (Array.isArray(snapResArr) && snapResArr[0] && snapResArr[0].id) {- const snapshot: ResticSnapshot = snapResArr[0];- return {- success: true,- result: snapshot,- };- } else {- return failedObj;- }- } else {- return failedObj;- }+ const [snapshot] = await getSnapshotsByTag(tag, options);+ return snapshot ? { success: true, result: snapshot } : failedObj;} catch (error: any) {return {...failedObj,diff --git a/frontend/src/@types/restores.ts b/frontend/src/@types/restores.tsindex a87dbd4..fdb809c 100644--- a/frontend/src/@types/restores.ts+++ b/frontend/src/@types/restores.ts@@ -117,3 +117,8 @@ export interface RestoreSettings {replicationId?: string;storageId?: string;}++// An edition can replace the restore path column for some plan methods through the 'RestoreTargetColumn' override.+export type RestoreTargetColumnResolver = (+ method: string,+) => { title: string; label: (restore: RestoreSlim) => string; tooltip?: (restore: RestoreSlim) => string } | undefined;diff --git a/frontend/src/components/Plan/BackupEvents/BackupEvents.tsx b/frontend/src/components/Plan/BackupEvents/BackupEvents.tsxindex 8a74470..e90658d 100644--- a/frontend/src/components/Plan/BackupEvents/BackupEvents.tsx+++ b/frontend/src/components/Plan/BackupEvents/BackupEvents.tsx@@ -1,6 +1,6 @@import Icon from '../../common/Icon/Icon';import SidePanel from '../../common/SidePanel/SidePanel';-import { getBackupEventActionMessage, getRestoreEventActionMessage } from '../../../utils/progressHelpers';+import { getBackupEventActionMessage, getRestoreEventActionMessage, isWarningAction } from '../../../utils/progressHelpers';import classes from './BackupEvents.module.scss';import { BackupProgressData, ReplicationProgressData } from '../../../@types/backups';import { useGetBackupProgressOnce } from '../../../services/backups';@@ -75,11 +75,7 @@ const BackupEvents = ({ id, type = 'backup', sourceId, sourceType, planId, inProconst failed = event.phase === 'finished' && event.action === 'FAILED_PERMANENTLY';const retrying = event.action.includes('RETRY_ATTEMPT_');const isError = event.action === 'TASK_FAILED';- const isWarning =- event.action === 'BACKUP_WARNING' ||- event.action === 'RESTORE_WARNING' ||- event.action === 'POST_BACKUP_PRUNE_FAILED' ||- event.action === 'POST_BACKUP_REPO_STATS_FAILED';+ const isWarning = isWarningAction(event.action);return (<likey={index}@@ -98,7 +94,7 @@ const BackupEvents = ({ id, type = 'backup', sourceId, sourceType, planId, inPro{type === 'backup' ? getBackupEventActionMessage(event.action) : getRestoreEventActionMessage(event.action)}{event.error && (<span className={classes.viewError} onClick={() => setShowError(`main-${index}`)}>- View Error+ View Details</span>)}</span>@@ -137,7 +133,7 @@ const BackupEvents = ({ id, type = 'backup', sourceId, sourceType, planId, inPro{getBackupEventActionMessage(event.action, mirror.storageName)}{event.error && (<span className={classes.viewError} onClick={() => setShowError(`mirror-${storageId}-${index}`)}>- View Error+ View Details</span>)}</span>diff --git a/frontend/src/components/Plan/Restores/Restores.tsx b/frontend/src/components/Plan/Restores/Restores.tsxindex 4e0b51c..1892314 100644--- a/frontend/src/components/Plan/Restores/Restores.tsx+++ b/frontend/src/components/Plan/Restores/Restores.tsx@@ -1,16 +1,16 @@-import { useState } from 'react';+import { useContext, useState } from 'react';import { toast } from 'react-toastify';import { useQueryClient } from '@tanstack/react-query';import Icon from '../../common/Icon/Icon';import ActionModal from '../../common/ActionModal/ActionModal';-import { RestoreSlim } from '../../../@types/restores';+import { RestoreSlim, RestoreTargetColumnResolver } from '../../../@types/restores';import { formatBytes, formatDateTime, formatDuration, formatNumberToK, timeAgo } from '../../../utils/helpers';import classes from '../Backups/Backups.module.scss';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';+import { ComponentOverrideContext, useComponentOverride } from '../../../context/ComponentOverrideContext';const DefaultRowActions = () => null;const DefaultRowMenuActions = () => null;@@ -34,6 +34,8 @@ const Restores = ({const [showRestoreEvents, setShowRestoreEvents] = useState<false | string>(false);const RowActions = useComponentOverride('RestoreRowActions', DefaultRowActions);const RowMenuActions = useComponentOverride('RestoreRowMenuActions', DefaultRowMenuActions);+ const resolveTargetColumn = useContext(ComponentOverrideContext)['RestoreTargetColumn'] as unknown as RestoreTargetColumnResolver | undefined;+ const targetColumn = resolveTargetColumn?.(method);const queryClient = useQueryClient();const deleteRestoreMutation = useDeleteRestore();@@ -59,7 +61,7 @@ const Restores = ({<div>Restored Backup</div><div>Status</div><div>Duration</div>- <div>Restore Path</div>+ <div>{targetColumn?.title || 'Restore Path'}</div><div>Files</div><div>Date</div><div></div>@@ -90,8 +92,13 @@ const Restores = ({<StatusLabel status={status} hasError={!!errorMsg} /></div><div title={duration + 's'}>{formatDuration(duration)}</div>- <div className={classes.target} data-tooltip-id="htmlToolTip" data-tooltip-html={`${config.target}`}>- {config.target || 'Original'}+ <div+ className={classes.target}+ data-tooltip-id="htmlToolTip"+ data-tooltip-html={targetColumn ? targetColumn.tooltip?.(restore) : `${config.target}`}+ data-tooltip-hidden={!!targetColumn && !targetColumn.tooltip}+ >+ {targetColumn ? targetColumn.label(restore) : config.target || 'Original'}</div><div data-tooltip-id="" data-tooltip-html={formatBytes(taskStats?.bytes_restored || 0)}>{formatNumberToK(taskStats?.files_restored || 0)}diff --git a/frontend/src/utils/helpers.ts b/frontend/src/utils/helpers.tsindex 3fc4e0d..9013114 100644--- a/frontend/src/utils/helpers.ts+++ b/frontend/src/utils/helpers.ts@@ -581,5 +581,8 @@ export const getBackupIconName = (method: string, sourceType?: string): string =if (method === 'vm') {return 'vm-backup';}+ if (method === 'database') {+ return 'database';+ }return 'backup';};diff --git a/frontend/src/utils/progressHelpers.ts b/frontend/src/utils/progressHelpers.tsindex eee5d33..325ce65 100644--- a/frontend/src/utils/progressHelpers.ts+++ b/frontend/src/utils/progressHelpers.ts@@ -16,6 +16,15 @@ export const registerPhaseDisplayNames = (names: Record<string, string>): void =Object.assign(registeredPhaseNames, names);};+// Actions that the event list shows as warnings, not as errors+const warningActions = new Set(['BACKUP_WARNING', 'RESTORE_WARNING', 'POST_BACKUP_PRUNE_FAILED', 'POST_BACKUP_REPO_STATS_FAILED']);++export const registerWarningActions = (actions: string[]): void => {+ actions.forEach((action) => warningActions.add(action));+};++export const isWarningAction = (action: string): boolean => warningActions.has(action);+// Turn an unmapped action code (e.g. SOME_ACTION_START) into readable textconst humanizeAction = (action: string): string =>action