From 2bc949fae3e96a8f77e354f447e7a92149ef1421 Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Mon, 15 Jul 2024 23:58:05 -0400 Subject: [PATCH 1/4] feat: adds support for allowing backups of unlimited size --- client/pages/config/backups.vue | 7 +++---- server/managers/BackupManager.js | 20 +++++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/client/pages/config/backups.vue b/client/pages/config/backups.vue index f78451193f..a88cfc235c 100644 --- a/client/pages/config/backups.vue +++ b/client/pages/config/backups.vue @@ -64,7 +64,7 @@ -

{{ $strings.LabelBackupsMaxBackupSize }} info

+

{{ $strings.LabelBackupsMaxBackupSize }} (0 for unlimited) info

@@ -170,7 +170,7 @@ export default { }) }, updateBackupsSettings() { - if (isNaN(this.maxBackupSize) || this.maxBackupSize <= 0) { + if (isNaN(this.maxBackupSize) || this.maxBackupSize < 0) { this.$toast.error('Invalid maximum backup size') return } @@ -200,10 +200,9 @@ export default { }, initServerSettings() { this.newServerSettings = this.serverSettings ? { ...this.serverSettings } : {} - this.backupsToKeep = this.newServerSettings.backupsToKeep || 2 this.enableBackups = !!this.newServerSettings.backupSchedule - this.maxBackupSize = this.newServerSettings.maxBackupSize || 1 + this.maxBackupSize = this.newServerSettings.maxBackupSize || 0 this.cronExpression = this.newServerSettings.backupSchedule || '30 1 * * *' } }, diff --git a/server/managers/BackupManager.js b/server/managers/BackupManager.js index 88772c586b..1349395217 100644 --- a/server/managers/BackupManager.js +++ b/server/managers/BackupManager.js @@ -42,7 +42,7 @@ class BackupManager { } get maxBackupSize() { - return global.ServerSettings.maxBackupSize || 1 + return global.ServerSettings.maxBackupSize || Infinity } async init() { @@ -419,14 +419,16 @@ class BackupManager { reject(err) }) archive.on('progress', ({ fs: fsobj }) => { - const maxBackupSizeInBytes = this.maxBackupSize * 1000 * 1000 * 1000 - if (fsobj.processedBytes > maxBackupSizeInBytes) { - Logger.error(`[BackupManager] Archiver is too large - aborting to prevent endless loop, Bytes Processed: ${fsobj.processedBytes}`) - archive.abort() - setTimeout(() => { - this.removeBackup(backup) - output.destroy('Backup too large') // Promise is reject in write stream error evt - }, 500) + if (this.maxBackupSize !== Infinity) { + const maxBackupSizeInBytes = this.maxBackupSize * 1000 * 1000 * 1000 + if (fsobj.processedBytes > maxBackupSizeInBytes) { + Logger.error(`[BackupManager] Archiver is too large - aborting to prevent endless loop, Bytes Processed: ${fsobj.processedBytes}`) + archive.abort() + setTimeout(() => { + this.removeBackup(backup) + output.destroy('Backup too large') // Promise is reject in write stream error evt + }, 500) + } } }) From e230b6640f0b24e1369a8410feb42531ff2d12b4 Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Tue, 16 Jul 2024 01:11:20 -0400 Subject: [PATCH 2/4] feat: adds unlimited text to text label --- client/pages/config/backups.vue | 2 +- client/strings/en-us.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/pages/config/backups.vue b/client/pages/config/backups.vue index a88cfc235c..d72c2bc894 100644 --- a/client/pages/config/backups.vue +++ b/client/pages/config/backups.vue @@ -64,7 +64,7 @@ -

{{ $strings.LabelBackupsMaxBackupSize }} (0 for unlimited) info

+

{{ $strings.LabelBackupsMaxBackupSize }} info

diff --git a/client/strings/en-us.json b/client/strings/en-us.json index a0933d4d48..9fdff867c2 100644 --- a/client/strings/en-us.json +++ b/client/strings/en-us.json @@ -229,7 +229,7 @@ "LabelBackupLocation": "Backup Location", "LabelBackupsEnableAutomaticBackups": "Enable automatic backups", "LabelBackupsEnableAutomaticBackupsHelp": "Backups saved in /metadata/backups", - "LabelBackupsMaxBackupSize": "Maximum backup size (in GB)", + "LabelBackupsMaxBackupSize": "Maximum backup size (in GB) (0 for unlimited)", "LabelBackupsMaxBackupSizeHelp": "As a safeguard against misconfiguration, backups will fail if they exceed the configured size.", "LabelBackupsNumberToKeep": "Number of backups to keep", "LabelBackupsNumberToKeepHelp": "Only 1 backup will be removed at a time so if you already have more backups than this you should manually remove them.", From 4b482488defe34ced7359de5db40c61d2fa85137 Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Tue, 16 Jul 2024 01:30:00 -0400 Subject: [PATCH 3/4] feat: remember setting of 0 on server side --- server/objects/settings/ServerSettings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/objects/settings/ServerSettings.js b/server/objects/settings/ServerSettings.js index 6ade11a9dd..6d070dcc07 100644 --- a/server/objects/settings/ServerSettings.js +++ b/server/objects/settings/ServerSettings.js @@ -102,7 +102,7 @@ class ServerSettings { this.backupPath = settings.backupPath || Path.join(global.MetadataPath, 'backups') this.backupSchedule = settings.backupSchedule || false this.backupsToKeep = settings.backupsToKeep || 2 - this.maxBackupSize = settings.maxBackupSize || 1 + this.maxBackupSize = settings.maxBackupSize === 0 ? 0 : settings.maxBackupSize || 1 this.loggerDailyLogsToKeep = settings.loggerDailyLogsToKeep || 7 this.loggerScannerLogsToKeep = settings.loggerScannerLogsToKeep || 2 From ff788e3591dcb51e9c3a2ee48af5720ade267486 Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Tue, 16 Jul 2024 01:31:12 -0400 Subject: [PATCH 4/4] feat: adds better conditional for max backup size --- client/pages/config/backups.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/pages/config/backups.vue b/client/pages/config/backups.vue index d72c2bc894..44a92f2e9f 100644 --- a/client/pages/config/backups.vue +++ b/client/pages/config/backups.vue @@ -202,7 +202,7 @@ export default { this.newServerSettings = this.serverSettings ? { ...this.serverSettings } : {} this.backupsToKeep = this.newServerSettings.backupsToKeep || 2 this.enableBackups = !!this.newServerSettings.backupSchedule - this.maxBackupSize = this.newServerSettings.maxBackupSize || 0 + this.maxBackupSize = this.newServerSettings.maxBackupSize === 0 ? 0 : this.newServerSettings.maxBackupSize || 1 this.cronExpression = this.newServerSettings.backupSchedule || '30 1 * * *' } },