Skip to content

A modern, self-hosted backup solution for secure, encrypted backups across local and cloud storage.

chore: facilitate pro edition's new storage sync plan

towfiqieeb6199eb740
diff --git a/backend/__tests__/services/PlanService.test.ts b/backend/__tests__/services/PlanService.test.ts
index 07da986..5e07a05 100644
--- a/backend/__tests__/services/PlanService.test.ts
+++ b/backend/__tests__/services/PlanService.test.ts
@@ -242,6 +242,82 @@ describe('PlanService', () => {
});
});
+ // -------------------------------------
+ // Tests for creating a storage-to-storage sync plan
+ // -------------------------------------
+ describe('createPlan with a storage source', () => {
+ beforeEach(() => {
+ performBackupSpy = jest
+ .spyOn(planService, 'performBackup')
+ .mockImplementation(() => Promise.resolve(''));
+ });
+
+ afterEach(() => {
+ performBackupSpy.mockRestore();
+ });
+
+ const localStoragePath = process.platform === 'win32' ? 'C:\\backups\\test' : '/backups/test';
+
+ const storagePlanData: NewPlanReq = {
+ title: 'Storage Sync Plan',
+ storage: { id: 'dest-storage', name: 'Dest Storage' },
+ storagePath: localStoragePath,
+ sourceId: 'source-storage',
+ sourceType: 'storage',
+ sourceConfig: { includes: ['some/path'], excludes: [] },
+ method: 'sync',
+ tags: [],
+ settings: {
+ interval: { type: 'daily', time: '10:00AM' },
+ } as PlanBackupSettings,
+ } as any;
+
+ beforeEach(() => {
+ mockStorageStore.getById.mockImplementation(async (id: string) => {
+ if (id === 'dest-storage') {
+ return { id: 'dest-storage', name: 'Dest Storage', type: 'local' } as any;
+ }
+ if (id === 'source-storage') {
+ return { id: 'source-storage', name: 'SourceRemote', type: 's3' } as any;
+ }
+ return null;
+ });
+ mockPlanStore.create.mockImplementation((data: any) =>
+ Promise.resolve({ id: 'plan-sync', ...data })
+ );
+ });
+
+ it('bakes the source remote:path into sourceConfig.includes[0]', async () => {
+ await planService.createPlan(storagePlanData);
+
+ expect(mockPlanStore.create).toHaveBeenCalledWith(
+ expect.objectContaining({
+ sourceConfig: expect.objectContaining({
+ includes: ['SourceRemote:some/path'],
+ }),
+ })
+ );
+ });
+
+ it('does not look up a source device', async () => {
+ await planService.createPlan(storagePlanData);
+
+ expect(mockDeviceStore.getById).not.toHaveBeenCalled();
+ });
+
+ it('rejects when the source storage is the same as the destination storage', async () => {
+ const badData = { ...storagePlanData, sourceId: 'dest-storage' };
+
+ await expect(planService.createPlan(badData)).rejects.toHaveProperty('statusCode', 400);
+ });
+
+ it('rejects a storage source when the method is not sync', async () => {
+ const badData = { ...storagePlanData, method: 'backup' };
+
+ await expect(planService.createPlan(badData)).rejects.toHaveProperty('statusCode', 400);
+ });
+ });
+
// -------------------------
// Tests for updating a plan
// -------------------------
@@ -354,6 +430,73 @@ describe('PlanService', () => {
});
});
+ // -------------------------------------
+ // Tests for updating a storage-to-storage sync plan
+ // -------------------------------------
+ describe('updatePlan on a storage-source plan', () => {
+ const planId = 'plan-storage-sync';
+ const currentPlan = {
+ id: planId,
+ title: 'Sync Plan',
+ sourceId: 'source-storage',
+ sourceType: 'storage',
+ storageId: 'dest-storage',
+ sourceConfig: { includes: ['SourceRemote:old/path'], excludes: [] },
+ settings: {
+ interval: { type: 'daily', time: '10:00AM' },
+ },
+ } as any;
+
+ beforeEach(() => {
+ mockPlanStore.getById.mockResolvedValue(currentPlan);
+ mockPlanStore.update.mockImplementation((id: string, data: any) =>
+ Promise.resolve({ ...currentPlan, ...data })
+ );
+ mockStorageStore.getById.mockImplementation(async (id: string) => {
+ if (id === 'dest-storage') {
+ return { id: 'dest-storage', name: 'Dest Storage', type: 'local' } as any;
+ }
+ if (id === 'source-storage') {
+ return { id: 'source-storage', name: 'SourceRemote', type: 's3' } as any;
+ }
+ return null;
+ });
+ });
+
+ it('re-bakes sourceConfig.includes[0] from a fresh path', async () => {
+ await planService.updatePlan(planId, {
+ sourceConfig: { includes: ['new/path'], excludes: [] },
+ } as any);
+
+ expect(mockPlanStore.update).toHaveBeenCalledWith(
+ planId,
+ expect.objectContaining({
+ sourceConfig: expect.objectContaining({ includes: ['SourceRemote:new/path'] }),
+ })
+ );
+ });
+
+ it('is idempotent when the incoming value is already prefixed with the remote name', async () => {
+ await planService.updatePlan(planId, {
+ sourceConfig: { includes: ['SourceRemote:new/path'], excludes: [] },
+ } as any);
+
+ expect(mockPlanStore.update).toHaveBeenCalledWith(
+ planId,
+ expect.objectContaining({
+ sourceConfig: expect.objectContaining({ includes: ['SourceRemote:new/path'] }),
+ })
+ );
+ });
+
+ it('rejects changing the source storage with a 400', async () => {
+ await expect(
+ planService.updatePlan(planId, { sourceId: 'other-storage' } as any)
+ ).rejects.toHaveProperty('statusCode', 400);
+ expect(mockPlanStore.update).not.toHaveBeenCalled();
+ });
+ });
+
// -------------------------
// Tests for deleting a plan
// -------------------------
@@ -1049,7 +1192,7 @@ describe('PlanService', () => {
schedulesMap.set('plan-orphan', [{ type: 'backup', options: {} }]);
mockCronManager.getSchedules.mockResolvedValue(schedulesMap);
mockCronManager.removeSchedule.mockResolvedValue(undefined);
- mockPlanStore.getDevicePlans.mockResolvedValue([]);
+ mockPlanStore.getAll = jest.fn().mockResolvedValue([]);
// Act
await planService.reconcileSchedules();
@@ -1059,12 +1202,30 @@ describe('PlanService', () => {
expect(mockCronManager.removeSchedule).toHaveBeenCalledTimes(1);
});
+ it('should not remove the schedule of a storage-source plan as an orphan', async () => {
+ // A storage-source plan has a storage id in sourceId, not 'main'
+ const storagePlan = makePlan('plan-storage', {
+ sourceId: 'storage-src-1',
+ sourceType: 'storage',
+ method: 'sync',
+ });
+ const schedulesMap = new Map();
+ schedulesMap.set('plan-storage', [{ type: 'sync', options: {} }]);
+ mockCronManager.getSchedules.mockResolvedValue(schedulesMap);
+ mockCronManager.removeSchedule.mockResolvedValue(undefined);
+ mockPlanStore.getAll = jest.fn().mockResolvedValue([storagePlan]);
+
+ await planService.reconcileSchedules();
+
+ expect(mockCronManager.removeSchedule).not.toHaveBeenCalled();
+ });
+
it('should recreate missing schedules for plans in the database', async () => {
// Arrange: DB has a plan but CronManager has no schedules
const plan = makePlan('plan-missing');
const schedulesMap = new Map();
mockCronManager.getSchedules.mockResolvedValue(schedulesMap);
- mockPlanStore.getDevicePlans.mockResolvedValue([plan]);
+ mockPlanStore.getAll = jest.fn().mockResolvedValue([plan]);
mockStorageStore.getById.mockResolvedValue({
id: 'storage-123',
name: 'Test Storage',
@@ -1097,7 +1258,7 @@ describe('PlanService', () => {
const schedulesMap = new Map();
schedulesMap.set('plan-synced', [{ type: 'backup', options: {} }]);
mockCronManager.getSchedules.mockResolvedValue(schedulesMap);
- mockPlanStore.getDevicePlans.mockResolvedValue([plan]);
+ mockPlanStore.getAll = jest.fn().mockResolvedValue([plan]);
// Act
await planService.reconcileSchedules();
@@ -1112,7 +1273,7 @@ describe('PlanService', () => {
const planNoInterval = makePlan('plan-no-interval', { settings: {} });
const schedulesMap = new Map();
mockCronManager.getSchedules.mockResolvedValue(schedulesMap);
- mockPlanStore.getDevicePlans.mockResolvedValue([planNoInterval]);
+ mockPlanStore.getAll = jest.fn().mockResolvedValue([planNoInterval]);
// Act
await planService.reconcileSchedules();
@@ -1126,7 +1287,7 @@ describe('PlanService', () => {
const plan = makePlan('plan-bad-storage');
const schedulesMap = new Map();
mockCronManager.getSchedules.mockResolvedValue(schedulesMap);
- mockPlanStore.getDevicePlans.mockResolvedValue([plan]);
+ mockPlanStore.getAll = jest.fn().mockResolvedValue([plan]);
mockStorageStore.getById.mockResolvedValue(null); // Storage not found
// Act — should not throw
@@ -1143,7 +1304,7 @@ describe('PlanService', () => {
schedulesMap.set('plan-deleted', [{ type: 'backup', options: {} }]);
mockCronManager.getSchedules.mockResolvedValue(schedulesMap);
mockCronManager.removeSchedule.mockResolvedValue(undefined);
- mockPlanStore.getDevicePlans.mockResolvedValue([plan]);
+ mockPlanStore.getAll = jest.fn().mockResolvedValue([plan]);
mockStorageStore.getById.mockResolvedValue({
id: 'storage-123',
name: 'Test Storage',
@@ -1173,7 +1334,7 @@ describe('PlanService', () => {
const plan2 = makePlan('plan-ok', { storageId: 'storage-good' });
const schedulesMap = new Map();
mockCronManager.getSchedules.mockResolvedValue(schedulesMap);
- mockPlanStore.getDevicePlans.mockResolvedValue([plan1, plan2]);
+ mockPlanStore.getAll = jest.fn().mockResolvedValue([plan1, plan2]);
mockStorageStore.getById.mockImplementation(async (id: string) => {
if (id === 'storage-bad') return null; // Will cause getStorageDetails to throw
return {
diff --git a/backend/__tests__/services/StorageService.test.ts b/backend/__tests__/services/StorageService.test.ts
index c63dbb4..c7f0314 100644
--- a/backend/__tests__/services/StorageService.test.ts
+++ b/backend/__tests__/services/StorageService.test.ts
@@ -362,6 +362,7 @@ describe('StorageService', () => {
mockStorageStore.getById.mockResolvedValue(mockStorage);
mockPlanStore.getStoragePlans.mockResolvedValue([]); // No dependent plans
mockStorageStore.getReplicationPlans = jest.fn().mockResolvedValue([]);
+ mockPlanStore.getDevicePlans.mockResolvedValue([]);
mockStorageManager.deleteRemote.mockResolvedValue({ success: true, result: 'Deleted' });
mockStorageStore.delete.mockResolvedValue(true);
@@ -373,6 +374,19 @@ describe('StorageService', () => {
expect(result).toBe(true);
});
+ it('should still succeed when getDevicePlans returns null', async () => {
+ mockStorageStore.getById.mockResolvedValue(mockStorage);
+ mockPlanStore.getStoragePlans.mockResolvedValue([]);
+ mockStorageStore.getReplicationPlans = jest.fn().mockResolvedValue([]);
+ mockPlanStore.getDevicePlans.mockResolvedValue(null);
+ mockStorageManager.deleteRemote.mockResolvedValue({ success: true, result: 'Deleted' });
+ mockStorageStore.delete.mockResolvedValue(true);
+
+ const result = await storageService.deleteStorage(storageId);
+
+ expect(result).toBe(true);
+ });
+
it('should throw NotFoundError if storage does not exist', async () => {
mockStorageStore.getById.mockResolvedValue(null);
await expect(storageService.deleteStorage(storageId)).rejects.toThrow('Storage not found');
@@ -404,6 +418,19 @@ describe('StorageService', () => {
);
});
+ it('should throw AppError if the storage is used as a plan source', async () => {
+ mockStorageStore.getById.mockResolvedValue(mockStorage);
+ mockPlanStore.getStoragePlans.mockResolvedValue([]);
+ mockStorageStore.getReplicationPlans = jest.fn().mockResolvedValue([]);
+ mockPlanStore.getDevicePlans.mockResolvedValue([{ title: 'Sync Plan C' } as any]);
+
+ await expect(storageService.deleteStorage(storageId)).rejects.toThrow(AppError);
+ await expect(storageService.deleteStorage(storageId)).rejects.toThrow(
+ 'This Storage is used as a backup source by the following plans: Sync Plan C. Please remove them before deleting the Storage.'
+ );
+ expect(mockStorageManager.deleteRemote).not.toHaveBeenCalled();
+ });
+
it('should throw AppError if an active self-backup uses the storage', async () => {
mockStorageStore.getById.mockResolvedValue(mockStorage);
mockPlanStore.getStoragePlans.mockResolvedValue([]);
diff --git a/backend/src/services/PlanService.ts b/backend/src/services/PlanService.ts
index 3f57b24..f974e57 100644
--- a/backend/src/services/PlanService.ts
+++ b/backend/src/services/PlanService.ts
@@ -112,19 +112,44 @@ export class PlanService {
throw new NotFoundError('Storage not found.');
}
+ const isStorageSource = sourceType === 'storage';
+ let planSourceConfig = sourceConfig;
+
+ if (isStorageSource) {
+ if (method !== 'sync') {
+ throw new AppError(400, 'A storage source is only supported by the sync method.');
+ }
+ if (sourceId === storage.id) {
+ throw new AppError(
+ 400,
+ 'The source storage and the destination storage must be different.'
+ );
+ }
+ if (!sourceConfig?.includes?.[0]?.trim()) {
+ throw new AppError(400, 'A source path is required.');
+ }
+ if (settings?.replication?.storages?.some(s => s.storageId === sourceId)) {
+ throw new AppError(400, 'A replication storage must be different from the source storage.');
+ }
+ planSourceConfig = {
+ ...sourceConfig,
+ includes: [await this.bakeStorageSourcePath(sourceConfig?.includes?.[0], sourceId)],
+ };
+ }
+
// Fetch the device early so we can use its OS for cross-platform path sanitization.
// Without this, a Windows server would mangle Linux paths (e.g., /var/home → F:/var/home).
- const device = await this.deviceStore.getById(sourceId);
- if (!device) {
+ const device = isStorageSource ? null : await this.deviceStore.getById(sourceId);
+ if (!isStorageSource && !device) {
throw new NotFoundError('Source device not found');
}
let theStoragePath;
if (storagePath) {
try {
- const isRemote = sourceId !== 'main';
+ const isRemote = !isStorageSource && sourceId !== 'main';
const targetOS = isRemote
- ? device.platform
+ ? device?.platform
? device.platform.toLowerCase()
: undefined
: undefined;
@@ -145,7 +170,7 @@ export class PlanService {
storageId: storage.id,
storagePath: theStoragePath,
method,
- sourceConfig,
+ sourceConfig: planSourceConfig,
sourceId,
sourceType,
settings,
@@ -236,6 +261,30 @@ export class PlanService {
// Never let the immutable storageId reach the update.
delete (parsedPlanData as Record<string, unknown>).storageId;
+ if (parsedPlanData.sourceType !== currentPlan.sourceType) {
+ throw new AppError(400, 'The source type cannot be changed after the plan is created.');
+ }
+
+ if (currentPlan.sourceType === 'storage') {
+ if (parsedPlanData.sourceId != null && parsedPlanData.sourceId !== currentPlan.sourceId) {
+ throw new AppError(400, 'The source storage cannot be changed after the plan is created.');
+ }
+ const newSettings = parsedPlanData.settings || currentPlan.settings;
+ if (newSettings?.replication?.storages?.some(s => s.storageId === currentPlan.sourceId)) {
+ throw new AppError(400, 'A replication storage must be different from the source storage.');
+ }
+ if (parsedPlanData.sourceConfig) {
+ // A partial update without a source path must not re-bake to the remote root
+ const givenPath = parsedPlanData.sourceConfig.includes?.[0]?.trim();
+ parsedPlanData.sourceConfig = {
+ ...parsedPlanData.sourceConfig,
+ includes: givenPath
+ ? [await this.bakeStorageSourcePath(givenPath, currentPlan.sourceId)]
+ : currentPlan.sourceConfig.includes,
+ };
+ }
+ }
+
const updatedPlan = await this.planStore.update(planId, parsedPlanData as Partial<Plan>);
if (!updatedPlan) {
throw new AppError(500, 'Failed to update plan in the database.');
@@ -260,7 +309,7 @@ export class PlanService {
const strategy = this.getStrategy(updatedPlan) as BackupStrategy;
const updateRes = await strategy.updateBackup(planId, backupScheduleOptions);
if (!updateRes.success) {
- if (updatedPlan.sourceId !== 'main') {
+ if (updatedPlan.sourceType === 'device' && updatedPlan.sourceId !== 'main') {
// Revert the update in the database if remote update fails to avoid inconsistencies
await this.planStore.update(planId, currentPlan);
}
@@ -731,6 +780,24 @@ export class PlanService {
}
}
+ /**
+ * Builds the `remoteName:path` source that rclone reads for a storage-to-storage sync plan.
+ */
+ private async bakeStorageSourcePath(
+ sourcePath: string | undefined,
+ sourceStorageId: string
+ ): Promise<string> {
+ const sourceStorage = await this.getStorageDetails(sourceStorageId);
+ if (!sourceStorage.name || !sourceStorage.type) {
+ throw new NotFoundError('Source storage not found.');
+ }
+ const prefix = `${sourceStorage.name}:`;
+ const givenPath = (sourcePath || '').trim();
+ const rawPath = givenPath.startsWith(prefix) ? givenPath.slice(prefix.length) : givenPath;
+ const cleanPath = sanitizeStoragePath(rawPath, sourceStorage.type);
+ return `${sourceStorage.name}:${cleanPath}`;
+ }
+
private async getStorageDetails(storageId: string): Promise<BackupPlanArgs['storage']> {
const storage = await this.storageStore.getById(storageId);
if (!storage) {
diff --git a/backend/src/services/RestoreService.ts b/backend/src/services/RestoreService.ts
index 4bde478..33ba3df 100644
--- a/backend/src/services/RestoreService.ts
+++ b/backend/src/services/RestoreService.ts
@@ -20,8 +20,8 @@ export class RestoreService {
protected storageStore: StorageStore
) {}
- getRestoreStrategy(deviceId: string, method: string): RestoreStrategy {
- const isRemote = deviceId !== 'main';
+ getRestoreStrategy(deviceId: string, method: string, sourceType?: string): RestoreStrategy {
+ const isRemote = sourceType !== 'storage' && deviceId !== 'main';
return isRemote ? new RemoteStrategy(deviceId) : new LocalStrategy(this.localAgent);
}
@@ -43,7 +43,7 @@ export class RestoreService {
if (!restore) {
throw new NotFoundError('Restore not found');
}
- const strategy = this.getRestoreStrategy(restore.sourceId, restore.method);
+ const strategy = this.getRestoreStrategy(restore.sourceId, restore.method, restore.sourceType);
const statsRes = await strategy.getRestoreStats(restore.planId as string, restoreId);
return statsRes;
@@ -94,7 +94,7 @@ export class RestoreService {
}
}
- const strategy = this.getRestoreStrategy(backupDevice, backup.method);
+ const strategy = this.getRestoreStrategy(backupDevice, backup.method, backup.sourceType);
const restoreResult = await strategy.getRestoreSnapshotStats(
backup.planId as string,
backup.id,
@@ -159,7 +159,7 @@ export class RestoreService {
}
}
- const strategy = this.getRestoreStrategy(backupDevice, plan.method);
+ const strategy = this.getRestoreStrategy(backupDevice, plan.method, plan.sourceType);
const restoreResult = await strategy.restoreSnapshot(backup.planId as string, backup.id, {
planId: backup.planId as string,
storageName: storageName,
@@ -189,7 +189,11 @@ export class RestoreService {
if (!restore) {
throw new NotFoundError('Restore not found');
}
- const strategy = this.getRestoreStrategy(restore.sourceId as string, restore.method);
+ const strategy = this.getRestoreStrategy(
+ restore.sourceId as string,
+ restore.method,
+ restore.sourceType
+ );
const cancelResult = await strategy.cancelSnapshotRestore(restore.planId as string, restoreId);
await this.restoreStore.update(restoreId, {
status: 'cancelled',
@@ -204,7 +208,11 @@ export class RestoreService {
if (!restore) {
throw new NotFoundError('Restore not found');
}
- const strategy = this.getRestoreStrategy(restore.sourceId as string, restore.method);
+ const strategy = this.getRestoreStrategy(
+ restore.sourceId as string,
+ restore.method,
+ restore.sourceType
+ );
const progressResult = await strategy.getRestoreProgress(restore.planId as string, restoreId);
if (!progressResult.success) {
throw new Error((progressResult.result as string) || 'Failed to get Restore Progress');
diff --git a/backend/src/services/ScheduleReconciler.ts b/backend/src/services/ScheduleReconciler.ts
index 35c2bad..350dfe6 100644
--- a/backend/src/services/ScheduleReconciler.ts
+++ b/backend/src/services/ScheduleReconciler.ts
@@ -55,7 +55,8 @@ export class ScheduleReconciler {
}
protected async getReconciliationPlans(): Promise<Plan[]> {
- return (await this.planStore.getDevicePlans('main')) || [];
+ const allPlans = (await this.planStore.getAll(false)) || [];
+ return allPlans.filter(plan => plan.sourceId === 'main' || plan.sourceType === 'storage');
}
protected async removeOrphanedSchedules(
@@ -104,19 +105,14 @@ export class ScheduleReconciler {
};
}
- protected async reconcileMissingSchedule(
- planId: string,
- plan: Plan | NewPlan
- ): Promise<boolean> {
+ protected async reconcileMissingSchedule(planId: string, plan: Plan | NewPlan): Promise<boolean> {
const backupScheduleOptions = await this.buildReconciliationScheduleOptions(planId, plan);
if (!backupScheduleOptions) {
return false;
}
await this.localAgent.createOrUpdateSchedules(planId, backupScheduleOptions, 'create');
- console.log(
- `[Reconciliation] Recreated missing schedule for plan "${plan.title}" (${planId})`
- );
+ console.log(`[Reconciliation] Recreated missing schedule for plan "${plan.title}" (${planId})`);
return true;
}
@@ -136,4 +132,4 @@ export class ScheduleReconciler {
defaultPath: storage.defaultPath as string,
};
}
-}
\ No newline at end of file
+}
diff --git a/backend/src/services/StorageService.ts b/backend/src/services/StorageService.ts
index 16d4caf..c28e21e 100644
--- a/backend/src/services/StorageService.ts
+++ b/backend/src/services/StorageService.ts
@@ -279,6 +279,16 @@ export class StorageService {
`This Storage is used as a replication target by the following plans: ${planTitles}. Please remove it from their replication settings before deleting the storage.`
);
}
+ // Disallow removing a storage that is used as a source for storage-sync plans.
+ // Storage-to-storage sync plans hold the source storage id in `plans.sourceId`.
+ const sourcePlans = await this.planStore.getDevicePlans(id);
+ if (sourcePlans && sourcePlans.length > 0) {
+ const planTitles = sourcePlans.map(p => p.title).join(', ');
+ throw new AppError(
+ 400,
+ `This Storage is used as a backup source by the following plans: ${planTitles}. Please remove them before deleting the Storage.`
+ );
+ }
const settingsRow = await this.settingsStore.getFirst();
const selfBackup = resolveSelfBackup(settingsRow?.settings);
diff --git a/backend/src/types/source.ts b/backend/src/types/source.ts
index 8c3b0e0..c2cc703 100644
--- a/backend/src/types/source.ts
+++ b/backend/src/types/source.ts
@@ -1,4 +1,4 @@
-export type SourceTypes = 'device' | 'database' | 'googleworkspace' | 'microsoft365';
+export type SourceTypes = 'device' | 'storage' | 'database' | 'googleworkspace' | 'microsoft365';
export type SqlDatabaseConfig = {
engine: 'postgres' | 'mysql' | 'mongodb';
diff --git a/frontend/src/@types/plans.ts b/frontend/src/@types/plans.ts
index 5963e60..f4ba2e9 100644
--- a/frontend/src/@types/plans.ts
+++ b/frontend/src/@types/plans.ts
@@ -181,7 +181,7 @@ export type Plan = {
lastUpdated: string | null;
storageId: string;
sourceId: string;
- sourceType: 'device' | 'database' | 'googleworkspace' | 'microsoft365';
+ sourceType: 'device' | 'storage' | 'database' | 'googleworkspace' | 'microsoft365';
storagePath: string;
sourceConfig: PlanSource;
tags: string[];
@@ -190,7 +190,7 @@ export type Plan = {
settings: PlanSettings;
storage: { name: string; type: string; id: string };
- device: { name: string; id: string; hostname: string };
+ device?: { name: string; id: string; hostname: string };
backups: Backup[];
restores?: RestoreSlim[];
};
@@ -205,7 +205,7 @@ export interface NewPlanSettings {
excludes: string[];
};
sourceId: string;
- sourceType: 'device' | 'database' | 'googleworkspace' | 'microsoft365';
+ sourceType: 'device' | 'storage' | 'database' | 'googleworkspace' | 'microsoft365';
storage: { id: string; name: string };
storagePath: string;
tags: string[];
diff --git a/frontend/src/components/Plan/FilterPlans/FilterPlans.tsx b/frontend/src/components/Plan/FilterPlans/FilterPlans.tsx
index 0885309..65ae332 100644
--- a/frontend/src/components/Plan/FilterPlans/FilterPlans.tsx
+++ b/frontend/src/components/Plan/FilterPlans/FilterPlans.tsx
@@ -29,14 +29,15 @@ const FilterPlans = ({ onUpdate, plans }: FilterPlansProps) => {
items.tags.push({ label: tag, value: tag });
}
});
- if (!items.devices.find((t) => t.value === plan.device.id)) {
+ if (plan.device && !items.devices.find((t) => t.value === plan.device?.id)) {
items.devices.push({ label: plan.device.name, value: plan.device.id });
}
if (!items.storages.find((t) => t.value === plan.storage.id)) {
items.storages.push({ label: plan.storage.name, value: plan.storage.id });
}
- if (!items.methods.find((t) => t.value === plan.method)) {
- items.methods.push({ label: plan.method, value: plan.method });
+ const methodValue = plan.sourceType === 'storage' ? 'storage-sync' : plan.method;
+ if (!items.methods.find((t) => t.value === methodValue)) {
+ items.methods.push({ label: methodValue === 'storage-sync' ? 'Storage Sync' : plan.method, value: methodValue });
}
});
return items;
diff --git a/frontend/src/components/Plan/PlanBackups/PlanBackups.tsx b/frontend/src/components/Plan/PlanBackups/PlanBackups.tsx
index 07dde0d..3773717 100644
--- a/frontend/src/components/Plan/PlanBackups/PlanBackups.tsx
+++ b/frontend/src/components/Plan/PlanBackups/PlanBackups.tsx
@@ -47,7 +47,7 @@ const PlanBackups = ({ plan }: PlanBackupsProps) => {
method={method}
sourceId={sourceId}
sourceType={sourceType}
- deviceId={plan.device.id}
+ deviceId={plan.device?.id || 'main'}
storage={storage}
snapLimit={settings.prune.snapCount}
replicationSettings={settings.replication}
diff --git a/frontend/src/components/Plan/PlanForm/PlanForm.tsx b/frontend/src/components/Plan/PlanForm/PlanForm.tsx
index 7883685..a0de61a 100644
--- a/frontend/src/components/Plan/PlanForm/PlanForm.tsx
+++ b/frontend/src/components/Plan/PlanForm/PlanForm.tsx
@@ -181,7 +181,7 @@ const PlanForm = ({
},
]}
/> */}
- {planSettings.sourceType === 'device' && (
+ {(planSettings.sourceType === 'device' || planSettings.sourceType === 'storage') && (
<PlanStrategySettings
plan={planSettings}
onUpdate={(method) => onPlanSettingsChange({ ...planSettings, method })}
@@ -195,11 +195,18 @@ const PlanForm = ({
},
{
value: 'sync',
- icon: 'reload',
+ icon: 'sync',
label: 'Real-time Sync',
description: 'Maintain identical source (with revisions)',
disabled: true,
},
+ {
+ value: 'storage-sync',
+ icon: 'storage-sync',
+ label: 'Storage Sync',
+ description: 'Sync one cloud storage to another cloud storage',
+ disabled: true,
+ },
{
value: 'rescue',
icon: 'rescue',
diff --git a/frontend/src/components/Plan/PlanItems/PlanItem.tsx b/frontend/src/components/Plan/PlanItems/PlanItem.tsx
index a594e8b..713cb60 100644
--- a/frontend/src/components/Plan/PlanItems/PlanItem.tsx
+++ b/frontend/src/components/Plan/PlanItems/PlanItem.tsx
@@ -2,10 +2,12 @@ import { useState } from 'react';
import { toast } from 'react-toastify';
import { NavLink } from 'react-router';
import { Plan } from '../../../@types/plans';
-import { formatBytes, formatDateTime, timeAgo } from '../../../utils/helpers';
+import { formatBytes, formatDateTime, getBackupIconName, timeAgo } from '../../../utils/helpers';
import Icon from '../../common/Icon/Icon';
+import StorageIcon from '../../common/Icon/StorageIcon';
import classes from './PlanItem.module.scss';
import { useDeletePlan, usePausePlan, usePerformBackup, useResumePlan } from '../../../services/plans';
+import { useGetStorages } from '../../../services/storage';
import { planIntervalName } from '../../../utils/plans';
import PlanHistory from '../PlanHistory/PlanHistory';
import PlanStorageInfo from '../PlanStorageInfo/PlanStorageInfo';
@@ -36,6 +38,12 @@ const PlanItem = ({ plan, layout = 'list' }: PlanItemProps) => {
const { interval = { type: 'daily', time: '10:00AM' }, encryption = false, compression = false } = settings;
const [showSettings, setShowSettings] = useState(false);
+ const isStorageSource = plan.sourceType === 'storage';
+ const { data: storageData } = useGetStorages();
+ const sourceStorage = isStorageSource
+ ? ((storageData?.result as { id: string; name: string; type: string }[]) || []).find((s) => s.id === plan.sourceId)
+ : undefined;
+
const deletePlanMutation = useDeletePlan();
const performBackupMutation = usePerformBackup();
const pauseMutation = usePausePlan();
@@ -106,7 +114,7 @@ const PlanItem = ({ plan, layout = 'list' }: PlanItemProps) => {
>
<div className={classes.leftContent}>
<div className={`${classes.status} ${!isActive ? classes.paused : ''} ${inProgress ? classes.inProgress : ''}`}>
- {inProgress ? <Icon type="loading" size={28} /> : <Icon type={method === 'backup' ? 'plans' : 'sync'} size={28} />}
+ {inProgress ? <Icon type="loading" size={28} /> : <Icon type={getBackupIconName(method, plan.sourceType)} size={28} />}
</div>
<div className={classes.content}>
@@ -150,10 +158,16 @@ const PlanItem = ({ plan, layout = 'list' }: PlanItemProps) => {
data-tooltip-place="top"
data-tooltip-html={sourceConfig?.includes ? sourceConfig.includes.map((p) => `<div>${p}</div>`).join('') : ''}
>
- {device?.name && (
+ {isStorageSource ? (
<>
- <Icon type={device.id === 'main' ? 'computer' : 'computer-remote'} size={13} /> {device.name}
+ <StorageIcon type={sourceStorage?.type} size={13} /> {sourceStorage?.name}
</>
+ ) : (
+ device?.name && (
+ <>
+ <Icon type={device.id === 'main' ? 'computer' : 'computer-remote'} size={13} /> {device.name}
+ </>
+ )
)}
<span className={classes.sourceCount}>{sourceConfig.includes.length}</span>
</span>{' '}
diff --git a/frontend/src/components/Plan/PlanSettings/PlanReplicationSettings.tsx b/frontend/src/components/Plan/PlanSettings/PlanReplicationSettings.tsx
index d9c45bb..90f7247 100644
--- a/frontend/src/components/Plan/PlanSettings/PlanReplicationSettings.tsx
+++ b/frontend/src/components/Plan/PlanSettings/PlanReplicationSettings.tsx
@@ -15,6 +15,7 @@ interface PlanReplicationSettingsProps {
primaryStorageId: string;
primaryStoragePath?: string;
deviceId: string;
+ excludeStorageIds?: string[];
isEditing?: boolean;
planID?: string;
maxReplications?: number;
@@ -34,6 +35,7 @@ const PlanReplicationSettings = ({
primaryStorageId,
primaryStoragePath,
deviceId,
+ excludeStorageIds,
isEditing = false,
planID,
maxReplications: maxReplicationsProp,
@@ -213,6 +215,7 @@ const PlanReplicationSettings = ({
storagePath={mirror.storagePath}
storageId={mirror.storageId}
deviceId={deviceId}
+ excludeStorageIds={excludeStorageIds}
disabled={isEditing}
onUpdate={(s) => {
if (s.storage.id === primaryStorageId && s.path === primaryStoragePath) {
@@ -259,6 +262,7 @@ const PlanReplicationSettings = ({
storagePath={tempStorage.storagePath}
storageId={tempStorage.storageId}
deviceId={deviceId}
+ excludeStorageIds={excludeStorageIds}
disabled={false}
onUpdate={(s) => {
updateTempStorage(index, {
diff --git a/frontend/src/components/Plan/PlanSettings/PlanSourceSettings.tsx b/frontend/src/components/Plan/PlanSettings/PlanSourceSettings.tsx
index ae9a386..85b0827 100644
--- a/frontend/src/components/Plan/PlanSettings/PlanSourceSettings.tsx
+++ b/frontend/src/components/Plan/PlanSettings/PlanSourceSettings.tsx
@@ -3,7 +3,9 @@ import classes from './PlanSettings.module.scss';
import PathPicker from '../../common/PathPicker/PathPicker';
import { NewPlanSettings } from '../../../@types/plans';
import { useGetDevices } from '../../../services/devices';
+import { useGetStorages } from '../../../services/storage';
import Select from '../../common/form/Select/Select';
+import StoragePicker from '../../common/form/StoragePicker/StoragePicker';
import { Device } from '../../../@types/devices';
interface PlanSourceSettingsProps {
@@ -15,6 +17,8 @@ interface PlanSourceSettingsProps {
const PlanSourceSettings = ({ plan, onUpdate, error, isEditing }: PlanSourceSettingsProps) => {
const { data } = useGetDevices();
+ const { data: storageData } = useGetStorages();
+ const isStorageSource = plan.sourceType === 'storage';
const deviceList = [];
const deviceId = plan.sourceId || 'main';
if (data?.success && data.result) {
@@ -33,7 +37,7 @@ const PlanSourceSettings = ({ plan, onUpdate, error, isEditing }: PlanSourceSett
// e.g. when navigating between steps in the Add Plan form).
const prevDeviceIdRef = useRef<string | null>(null);
useEffect(() => {
- if (isEditing) {
+ if (isEditing || isStorageSource) {
prevDeviceIdRef.current = deviceId;
return;
}
@@ -49,6 +53,36 @@ const PlanSourceSettings = ({ plan, onUpdate, error, isEditing }: PlanSourceSett
prevDeviceIdRef.current = deviceId;
}, [isEditing, deviceId]);
+ if (isStorageSource) {
+ const storages = (storageData?.result as { id: string; name: string }[]) || [];
+ const sourceStorage = storages.find((s) => s.id === plan.sourceId);
+ const prefix = sourceStorage ? `${sourceStorage.name}:` : '';
+ const bakedPath = plan.sourceConfig.includes[0] || '';
+ const sourcePath = prefix && bakedPath.startsWith(prefix) ? bakedPath.slice(prefix.length) : bakedPath;
+
+ return (
+ <div className={classes.field}>
+ <label className={classes.label}>Source Storage*</label>
+ {error && <span className={classes.fieldErrorLabel}>{error}</span>}
+ <StoragePicker
+ storageId={plan.sourceId}
+ storagePath={sourcePath}
+ deviceId="main"
+ excludeStorageIds={plan.storage.id ? [plan.storage.id] : []}
+ disabled={isEditing}
+ disabledHint="The source storage can't be changed after a plan is created."
+ onUpdate={(s) =>
+ onUpdate({
+ ...plan,
+ sourceId: s.storage.id,
+ sourceConfig: { ...plan.sourceConfig, includes: [s.path] },
+ })
+ }
+ />
+ </div>
+ );
+ }
+
return (
<>
<div className={classes.field}>
diff --git a/frontend/src/components/Plan/PlanSettings/PlanStrategySettings.tsx b/frontend/src/components/Plan/PlanSettings/PlanStrategySettings.tsx
index c6849a4..7c82f9e 100644
--- a/frontend/src/components/Plan/PlanSettings/PlanStrategySettings.tsx
+++ b/frontend/src/components/Plan/PlanSettings/PlanStrategySettings.tsx
@@ -26,7 +26,7 @@ const PlanStrategySettings = ({ plan, options = [], disabled = false, onUpdate }
<RadioIconSelect
label="Backup Strategy*"
options={options}
- fieldValue={plan.method}
+ fieldValue={plan.sourceType === 'storage' ? 'storage-sync' : plan.method}
onUpdate={(method) => onUpdate(method)}
onDisableClick={(value) => {
const option = options.find((opt) => opt.value === value);
diff --git a/frontend/src/components/Plan/PlanStats/PlanStats.tsx b/frontend/src/components/Plan/PlanStats/PlanStats.tsx
index bf8a99e..e7ac429 100644
--- a/frontend/src/components/Plan/PlanStats/PlanStats.tsx
+++ b/frontend/src/components/Plan/PlanStats/PlanStats.tsx
@@ -1,6 +1,8 @@
import Icon from '../../common/Icon/Icon';
+import StorageIcon from '../../common/Icon/StorageIcon';
import { Plan } from '../../../@types/plans';
-import { formatIntervalDisplay } from '../../../utils/helpers';
+import { useGetStorages } from '../../../services/storage';
+import { formatIntervalDisplay, getBackupIconName } from '../../../utils/helpers';
import PlanHistory from '../PlanHistory/PlanHistory';
import PlanSizeChart from '../PlanSizeChart/PlanSizeChart';
import classes from './PlanStats.module.scss';
@@ -16,6 +18,13 @@ interface PlanStatsProps {
const PlanStats = ({ plan, isSync, lastBackupItem }: PlanStatsProps) => {
const { sourceConfig, storage, storagePath, isActive, settings } = plan;
const { interval } = settings;
+ const isStorageSource = plan.sourceType === 'storage';
+
+ const { data: storageData } = useGetStorages();
+ const sourceStorage = isStorageSource
+ ? ((storageData?.result as { id: string; name: string; type: string }[]) || []).find((s) => s.id === plan.sourceId)
+ : undefined;
+ const sourceName = isStorageSource ? sourceStorage?.name || '' : plan.device?.name || '';
const totalFiles = lastBackupItem?.totalFiles || 0;
const totalSize = lastBackupItem?.totalSize || 0;
@@ -24,7 +33,7 @@ const PlanStats = ({ plan, isSync, lastBackupItem }: PlanStatsProps) => {
let html = '';
if (sources && sources.includes && sources.includes.length > 0) {
html += `<div><strong>Includes</strong></div>`;
- html += sources.includes.map((p) => `<div>${plan.device.name} -> ${p}</div>`).join('');
+ html += sources.includes.map((p) => `<div>${sourceName} -> ${p}</div>`).join('');
}
if (sources && sources.excludes && sources.excludes.length > 0) {
html += `<div><strong>Excludes</strong></div>`;
@@ -37,12 +46,12 @@ const PlanStats = ({ plan, isSync, lastBackupItem }: PlanStatsProps) => {
<div className={classes.planStats}>
<div className={classes.sources}>
<div className={classes.widgetTitle}>
- <Icon type="backup" size={12} /> {isSync ? 'Syncing' : 'Backing Up'}
+ <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)}>
- <Icon type="folders" size={18} />
- <span>{sourceConfig?.includes.length} Sources</span>
+ {isStorageSource ? <StorageIcon type={sourceStorage?.type} size={18} /> : <Icon type="folders" size={18} />}
+ <span>{isStorageSource ? sourceName : `${sourceConfig?.includes.length} Sources`}</span>
</div>
<div
data-tooltip-id="htmlToolTip"
diff --git a/frontend/src/components/Upgrade/Upgrade.tsx b/frontend/src/components/Upgrade/Upgrade.tsx
index ca0b30d..8b162a1 100644
--- a/frontend/src/components/Upgrade/Upgrade.tsx
+++ b/frontend/src/components/Upgrade/Upgrade.tsx
@@ -32,6 +32,9 @@ const Upgrade = ({ focus, onClose }: UpgradeProps) => {
<li className={tab === 'sync' ? classes.active : ''} onClick={() => setTab('sync')}>
<Icon type="sync" size={14} /> Sync Backups
</li>
+ <li className={tab === 'storage-sync' ? classes.active : ''} onClick={() => setTab('storage-sync')}>
+ <Icon type="storages" size={14} /> Storage Sync
+ </li>
<li className={tab === 'remote' ? classes.active : ''} onClick={() => setTab('remote')}>
<Icon type="computer-remote" size={14} /> Backup Remote Machines
</li>
@@ -80,6 +83,32 @@ const Upgrade = ({ focus, onClose }: UpgradeProps) => {
</div>
</div>
)}
+ {tab === 'storage-sync' && (
+ <div className={classes.tab}>
+ <h3>
+ <Icon type="storages" size={18} /> Unlock Cloud-to-Cloud Storage Sync
+ </h3>
+ <ul>
+ <li>
+ <Icon type="check-circle" size={14} /> Sync one cloud storage directly to another, with no local copy
+ </li>
+ <li>
+ <Icon type="check-circle" size={14} /> Keep a second provider up to date, so one provider is never a single point of
+ failure
+ </li>
+ <li>
+ <Icon type="check-circle" size={14} /> File revisions, exclude patterns, and integrity checks work the same as a device
+ sync
+ </li>
+ <li>
+ <Icon type="check-circle" size={14} /> Restore files back to the source storage at any time
+ </li>
+ </ul>
+ <div className={classes.tabImage}>
+ <img src="https://pluton.b-cdn.net/upgrade/features_pro_storage_sync.webp" />
+ </div>
+ </div>
+ )}
{tab === 'remote' && (
<div className={classes.tab}>
<h3>
@@ -235,21 +264,23 @@ const Upgrade = ({ focus, onClose }: UpgradeProps) => {
</div>
<div className={classes.mobileNav}>
<ul>
- {['sync', 'remote', 'recovery', 'snapshot', 'rescue', 'email'].map((item) => (
+ {['sync', 'storage-sync', 'remote', 'recovery', 'snapshot', 'rescue', 'email'].map((item) => (
<li key={item} className={tab === item ? classes.active : ''} onClick={() => setTab(item)}>
<Icon
type={
item === 'sync'
? 'sync'
- : item === 'remote'
- ? 'computer-remote'
- : item === 'recovery'
- ? 'integrity'
- : item === 'snapshot'
- ? 'box'
- : item === 'rescue'
- ? 'linux'
- : 'email'
+ : item === 'storage-sync'
+ ? 'storages'
+ : item === 'remote'
+ ? 'computer-remote'
+ : item === 'recovery'
+ ? 'integrity'
+ : item === 'snapshot'
+ ? 'box'
+ : item === 'rescue'
+ ? 'linux'
+ : 'email'
}
size={24}
/>
diff --git a/frontend/src/components/common/Icon/Icon.tsx b/frontend/src/components/common/Icon/Icon.tsx
index ca0797d..036c4c7 100644
--- a/frontend/src/components/common/Icon/Icon.tsx
+++ b/frontend/src/components/common/Icon/Icon.tsx
@@ -78,6 +78,14 @@ const Icon = ({ type, color = 'currentColor', size = 16, title = '', classes = '
</IconWrapper>
)}
{type === 'sync' && (
+ <IconWrapper size={size} viewBox="0 0 16 16">
+ <path
+ fill={color}
+ d="M2 4.5V6h3.586a.5.5 0 0 0 .353-.146L7.293 4.5L5.939 3.146A.5.5 0 0 0 5.586 3H3.5A1.5 1.5 0 0 0 2 4.5m-1 0A2.5 2.5 0 0 1 3.5 2h2.086a1.5 1.5 0 0 1 1.06.44L8.207 4H12.5A2.5 2.5 0 0 1 15 6.5v.757a5.5 5.5 0 0 0-1-.657v-.1A1.5 1.5 0 0 0 12.5 5H8.207l-1.56 1.56A1.5 1.5 0 0 1 5.585 7H2v4.5A1.5 1.5 0 0 0 3.5 13h2.707q.149.524.393 1H3.5A2.5 2.5 0 0 1 1 11.5zm6 7a4.5 4.5 0 1 0 9 0a4.5 4.5 0 0 0-9 0m6.5-3a.5.5 0 0 1 .5.5v1.5a.5.5 0 0 1-.5.5H12a.5.5 0 0 1 0-1h.468a2 2 0 0 0-.933-.25a2 2 0 0 0-1.45.586a.5.5 0 0 1-.706-.707A3 3 0 0 1 13 9.152V9a.5.5 0 0 1 .5-.5m-.876 5.532A3 3 0 0 1 10 13.848V14a.5.5 0 0 1-1 0v-1.5a.5.5 0 0 1 .5-.5H11a.5.5 0 0 1 0 1h-.468q.075.042.155.077a2 2 0 0 0 2.227-.413a.5.5 0 0 1 .707.707c-.285.285-.624.51-.997.66"
+ ></path>
+ </IconWrapper>
+ )}
+ {type === 'storage-sync' && (
<IconWrapper size={size} viewBox="0 0 16 16">
<path
fill={color}
diff --git a/frontend/src/components/common/Icon/StorageIcon.tsx b/frontend/src/components/common/Icon/StorageIcon.tsx
new file mode 100644
index 0000000..cfe6502
--- /dev/null
+++ b/frontend/src/components/common/Icon/StorageIcon.tsx
@@ -0,0 +1,19 @@
+import { useState } from 'react';
+import Icon from './Icon';
+
+interface StorageIconProps {
+ type?: string;
+ size?: number;
+}
+
+/** Shows the provider logo of a storage, and the generic storage icon for a local or unknown type. */
+const StorageIcon = ({ type, size = 13 }: StorageIconProps) => {
+ const [imageFailed, setImageFailed] = useState(false);
+
+ if (!type || type === 'local' || imageFailed) {
+ return <Icon type="storages" size={size} />;
+ }
+ return <img src={`/providers/${type}.png`} width={size} height={size} alt={type} onError={() => setImageFailed(true)} />;
+};
+
+export default StorageIcon;
diff --git a/frontend/src/components/common/form/StoragePicker/StoragePicker.tsx b/frontend/src/components/common/form/StoragePicker/StoragePicker.tsx
index 6941db3..8d883ea 100644
--- a/frontend/src/components/common/form/StoragePicker/StoragePicker.tsx
+++ b/frontend/src/components/common/form/StoragePicker/StoragePicker.tsx
@@ -14,10 +14,20 @@ interface StoragePickerProps {
storageId?: string;
disabled?: boolean;
deviceId?: string;
+ excludeStorageIds?: string[];
+ disabledHint?: string;
onUpdate: (val: { storage: storageItem; path: string }) => void;
}
-const StoragePicker = ({ onUpdate, storagePath = '', storageId, disabled = false, deviceId }: StoragePickerProps) => {
+const StoragePicker = ({
+ onUpdate,
+ storagePath = '',
+ storageId,
+ disabled = false,
+ deviceId,
+ excludeStorageIds,
+ disabledHint = "The destination path can't be changed after a plan is created.",
+}: StoragePickerProps) => {
const [selectedStorage, setSelectedStorage] = useState<null | storageItem>();
const [showFolderPicker, setShowFolderPicker] = useState(false);
const [showAddStorageModal, setShowAddStorageModal] = useState(false);
@@ -34,13 +44,24 @@ const StoragePicker = ({ onUpdate, storagePath = '', storageId, disabled = false
console.log('selectedStorage :', selectedStorage);
const storageOptions = useMemo(() => {
- const storageOpts = allStorages.map(({ name, id, type }) => ({
- label: name,
- value: id.toString(),
- image: <img src={`/providers/${type}.png`} />,
- }));
+ const storageOpts = allStorages
+ .filter(({ id }) => !excludeStorageIds?.includes(id))
+ .map(({ name, id, type }) => ({
+ label: name,
+ value: id.toString(),
+ image: <img src={`/providers/${type}.png`} />,
+ }));
return storageOpts;
- }, [allStorages]);
+ }, [allStorages, excludeStorageIds]);
+
+ // Clear the selection when the picked storage becomes excluded (e.g. the user
+ // selected it as the source of the same plan).
+ useEffect(() => {
+ if (selectedStorage && excludeStorageIds?.includes(selectedStorage.id)) {
+ setSelectedStorage(null);
+ setPath('');
+ }
+ }, [excludeStorageIds, selectedStorage]);
const selectStorage = (storageID: string) => {
console.log('storageID :', storageID);
@@ -94,7 +115,7 @@ const StoragePicker = ({ onUpdate, storagePath = '', storageId, disabled = false
{...(disabled
? {
'data-tooltip-id': 'appTooltip',
- 'data-tooltip-content': "The destination path can't be changed after a plan is created.",
+ 'data-tooltip-content': disabledHint,
'data-tooltip-place': 'top',
}
: {})}
diff --git a/frontend/src/components/index.ts b/frontend/src/components/index.ts
index 124e9df..bbb3a48 100644
--- a/frontend/src/components/index.ts
+++ b/frontend/src/components/index.ts
@@ -42,6 +42,7 @@ export { default as PasswordField } from './common/form/PasswordField/PasswordFi
export { default as RadioIconSelect } from './common/form/RadioIconSelect/RadioIconSelect';
export { default as Select } from './common/form/Select/Select';
export { default as SizePicker } from './common/form/SizePicker/SizePicker';
+export { default as StorageIcon } from './common/Icon/StorageIcon';
export { default as StoragePicker } from './common/form/StoragePicker/StoragePicker';
export { default as TagsInput } from './common/form/TagsInput/TagsInput';
export { default as TimePicker } from './common/form/TimePicker/TimePicker';
diff --git a/frontend/src/routes/PlanSingle/PlanSingle.module.scss b/frontend/src/routes/PlanSingle/PlanSingle.module.scss
index e2bc576..28b5065 100644
--- a/frontend/src/routes/PlanSingle/PlanSingle.module.scss
+++ b/frontend/src/routes/PlanSingle/PlanSingle.module.scss
@@ -19,6 +19,12 @@
.planActions {
position: relative;
+ display: flex;
+ .actionBtn {
+ display: flex;
+ align-items: center;
+ gap: 3px;
+ }
.moreOptions {
position: absolute;
width: max-content;
diff --git a/frontend/src/routes/PlanSingle/PlanSingle.tsx b/frontend/src/routes/PlanSingle/PlanSingle.tsx
index 02aea0f..0e5524c 100644
--- a/frontend/src/routes/PlanSingle/PlanSingle.tsx
+++ b/frontend/src/routes/PlanSingle/PlanSingle.tsx
@@ -17,6 +17,7 @@ import PlanBackups from '../../components/Plan/PlanBackups/PlanBackups';
import PlanIntegrity from '../../components/Plan/PlanIntegrity/PlanIntegrity';
import PlanRepair from '../../components/Plan/PlanRepair/PlanRepair';
import { PlanVerifiedResult } from '../..';
+import { getBackupIconName } from '../../utils';
const PlanSingle = () => {
const [showMoreOptions, setShowMoreOptions] = useState(false);
@@ -97,12 +98,12 @@ const PlanSingle = () => {
</>
}
pageTitle={title}
- icon="plans"
+ icon={getBackupIconName(method, plan.sourceType)}
rightSection={
<>
<div className={classes.planActions}>
<button className={classes.actionBtn} onClick={backupNow}>
- <Icon size={14} type={isSync ? 'sync' : 'backup'} /> {isSync ? 'Sync' : 'Backup'} Now
+ <Icon size={16} type={isSync ? 'reload' : 'backup'} /> {isSync ? 'Sync' : 'Backup'} Now
</button>
<button className={`${classes.actionBtn} ${!isActive ? classes.actionBtnHighlight : ''}`} onClick={changeStatus}>
<Icon size={14} type={isActive ? 'pause' : 'resume'} /> {isActive ? 'Pause' : 'Resume'}
diff --git a/frontend/src/routes/Plans/Plans.tsx b/frontend/src/routes/Plans/Plans.tsx
index fd3e2f7..db7439f 100644
--- a/frontend/src/routes/Plans/Plans.tsx
+++ b/frontend/src/routes/Plans/Plans.tsx
@@ -95,10 +95,12 @@ const Plans = () => {
let filteredPlans = plansToSort && plansToSort.length > 0 ? plansToSort : plans;
if (filter.devices.length > 0) {
- filteredPlans = filteredPlans.filter((plan) => filter.devices.includes(plan.device.id));
+ filteredPlans = filteredPlans.filter((plan) => !!plan.device && filter.devices.includes(plan.device.id));
}
if (filter.methods.length > 0) {
- filteredPlans = filteredPlans.filter((plan) => filter.methods.includes(plan.method));
+ filteredPlans = filteredPlans.filter((plan) =>
+ filter.methods.includes(plan.sourceType === 'storage' ? 'storage-sync' : plan.method)
+ );
}
if (filter.storages.length > 0) {
filteredPlans = filteredPlans.filter((plan) => filter.storages.includes(plan.storage.id));
diff --git a/frontend/src/utils/helpers.ts b/frontend/src/utils/helpers.ts
index de1de82..3b9a3f8 100644
--- a/frontend/src/utils/helpers.ts
+++ b/frontend/src/utils/helpers.ts
@@ -567,3 +567,16 @@ export const proViewFileFormatObj = {
};
export const proViewableFileFormats = Object.values(proViewFileFormatObj).flat();
+
+export const getBackupIconName = (method: string, sourceType?: string): string => {
+ if (method === 'sync' && sourceType === 'storage') {
+ return 'storage-sync';
+ }
+ if (method === 'sync') {
+ return 'sync';
+ }
+ if (method === 'rescue') {
+ return 'rescue';
+ }
+ return 'backup';
+};
diff --git a/frontend/src/utils/plans.ts b/frontend/src/utils/plans.ts
index c1a2325..49240b4 100644
--- a/frontend/src/utils/plans.ts
+++ b/frontend/src/utils/plans.ts
@@ -53,6 +53,16 @@ export function isPlanSettingsValid(newPlan: NewPlanSettings, step: number | fal
return false;
}
if (step === 2 || step === false) {
+ if (newPlan.sourceType === 'storage') {
+ if (!newPlan.sourceId) {
+ toast.error(`Source Storage is required`);
+ return false;
+ }
+ if (newPlan.storage.id === newPlan.sourceId) {
+ toast.error(`The source storage and the destination storage must be different`);
+ return false;
+ }
+ }
if (newPlan.sourceConfig.includes.length === 0) {
toast.error(`Sources are required`);
return false;