Skip to content

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

fix: resolves stuck backup issue after previous backup cancellation

towfiqi4cd3217a6642
diff --git a/backend/src/managers/handlers/BackupHandler.ts b/backend/src/managers/handlers/BackupHandler.ts
index da02c71..de85d94 100644
--- a/backend/src/managers/handlers/BackupHandler.ts
+++ b/backend/src/managers/handlers/BackupHandler.ts
@@ -90,13 +90,13 @@ export class BackupHandler {
// --- 1. PRE-BACKUP PHASE ---
const resticArgsAndEnv = this.createResticBackupArgs(planId, options as BackupPlanArgs);
await this.preBackupPhase(planId, backupId, options, resticArgsAndEnv);
- if (this.cancelledBackups.has(planId)) {
+ if (this.cancelledBackups.has(planId + backupId)) {
throw new Error('BACKUP_CANCELLED: Backup was cancelled');
}
// --- 2. BACKUP PHASE ---
const result = await this.executeBackupPhase(planId, backupId, options, resticArgsAndEnv);
- if (this.cancelledBackups.has(planId)) {
+ if (this.cancelledBackups.has(planId + backupId)) {
throw new Error('BACKUP_CANCELLED: Backup was cancelled');
}
@@ -134,7 +134,8 @@ export class BackupHandler {
// If Cancelled by the user, do not retry or mark as failed.
const isCancelled =
- errorMessage.startsWith('BACKUP_CANCELLED:') || this.cancelledBackups.has(planId);
+ errorMessage.startsWith('BACKUP_CANCELLED:') ||
+ this.cancelledBackups.has(planId + backupId);
if (isCancelled) {
return '';
}
@@ -195,7 +196,7 @@ export class BackupHandler {
} finally {
// This block runs regardless of success or failure, ensuring we always clean up.
this.runningBackups.delete(planId);
- this.cancelledBackups.delete(planId);
+ this.cancelledBackups.delete(planId + backupId);
}
}
@@ -303,7 +304,7 @@ export class BackupHandler {
handlers.onComplete,
process => processManager.trackProcess('backup-' + backupId, process)
);
- if (!this.cancelledBackups.has(planId)) {
+ if (!this.cancelledBackups.has(planId + backupId)) {
await this.updateProgress(planId, backupId, 'backup', 'BACKUP_OPERATION_COMPLETE', true);
}
return result;
@@ -549,7 +550,7 @@ export class BackupHandler {
* @returns A promise that resolves to a boolean indicating if the backup was cancelled.
*/
async cancel(planId: string, backupId: string): Promise<boolean> {
- this.cancelledBackups.add(planId);
+ this.cancelledBackups.add(planId + backupId);
await this.progressManager.markCompleted(
planId,
backupId,
diff --git a/backend/src/managers/handlers/ReplicationHandler.ts b/backend/src/managers/handlers/ReplicationHandler.ts
index 1632f81..2daa686 100644
--- a/backend/src/managers/handlers/ReplicationHandler.ts
+++ b/backend/src/managers/handlers/ReplicationHandler.ts
@@ -64,7 +64,7 @@ export class ReplicationHandler {
// Run replications sequentially
const results: BackupMirror[] = [];
for (let i = 0; i < resolvedStorages.length; i++) {
- if (this.cancelledBackups.has(planId)) {
+ if (this.cancelledBackups.has(planId + backupId)) {
// Mark remaining mirrors as failed
for (let j = i; j < resolvedStorages.length; j++) {
results.push({
@@ -127,7 +127,7 @@ export class ReplicationHandler {
try {
// Check for cancellation
- if (this.cancelledBackups.has(planId)) {
+ if (this.cancelledBackups.has(planId + backupId)) {
throw new Error('Cancelled by user');
}
@@ -178,7 +178,7 @@ export class ReplicationHandler {
}
// Check for cancellation
- if (this.cancelledBackups.has(planId)) {
+ if (this.cancelledBackups.has(planId + backupId)) {
throw new Error('Cancelled by user');
}
@@ -330,7 +330,7 @@ export class ReplicationHandler {
);
// Check for cancellation after copy
- if (this.cancelledBackups.has(planId)) {
+ if (this.cancelledBackups.has(planId + backupId)) {
throw new Error('Cancelled by user');
}
diff --git a/backend/src/managers/handlers/ReplicationOrchestrator.ts b/backend/src/managers/handlers/ReplicationOrchestrator.ts
index a9e8d3f..a667f86 100644
--- a/backend/src/managers/handlers/ReplicationOrchestrator.ts
+++ b/backend/src/managers/handlers/ReplicationOrchestrator.ts
@@ -218,7 +218,7 @@ export class ReplicationOrchestrator {
if (failedResults.length === 0) break;
// Check for cancellation before retrying
- if (this.cancelledBackups.has(planId)) break;
+ if (this.cancelledBackups.has(planId + backupId)) break;
attempt++;
const failedReplicationIds = new Set(failedResults.map(m => m.replicationId));
@@ -239,7 +239,7 @@ export class ReplicationOrchestrator {
await new Promise(resolve => setTimeout(resolve, delayMs));
// Check for cancellation after delay
- if (this.cancelledBackups.has(planId)) break;
+ if (this.cancelledBackups.has(planId + backupId)) break;
for (const replicationId of failedReplicationIds) {
await this.progressManager.updateReplicationAction(