From 37f62d22b624f49b31e7f3b1f7caeff0688deec5 Mon Sep 17 00:00:00 2001 From: Nicholas Wallace Date: Fri, 5 Jul 2024 17:27:49 +0000 Subject: [PATCH 1/5] Add: report whether backup path environment is set --- server/controllers/BackupController.js | 3 ++- server/managers/BackupManager.js | 4 ++++ server/objects/settings/ServerSettings.js | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/server/controllers/BackupController.js b/server/controllers/BackupController.js index 30defb0e..69eae30a 100644 --- a/server/controllers/BackupController.js +++ b/server/controllers/BackupController.js @@ -10,7 +10,8 @@ class BackupController { getAll(req, res) { res.json({ backups: this.backupManager.backups.map((b) => b.toJSON()), - backupLocation: this.backupManager.backupPath + backupLocation: this.backupManager.backupPath, + backupEnvSet: this.backupManager.backupPathEnvSet }) } diff --git a/server/managers/BackupManager.js b/server/managers/BackupManager.js index 2749cc7c..ae79569c 100644 --- a/server/managers/BackupManager.js +++ b/server/managers/BackupManager.js @@ -29,6 +29,10 @@ class BackupManager { return global.ServerSettings.backupPath } + get backupPathEnvSet() { + return global.ServerSettings.backupPathEnvSet + } + get backupSchedule() { return global.ServerSettings.backupSchedule } diff --git a/server/objects/settings/ServerSettings.js b/server/objects/settings/ServerSettings.js index 6ade11a9..d5519c52 100644 --- a/server/objects/settings/ServerSettings.js +++ b/server/objects/settings/ServerSettings.js @@ -26,6 +26,7 @@ class ServerSettings { this.rateLimitLoginWindow = 10 * 60 * 1000 // 10 Minutes // Backups + this.backupPathEnvSet = false this.backupPath = Path.join(global.MetadataPath, 'backups') this.backupSchedule = false // If false then auto-backups are disabled this.backupsToKeep = 2 @@ -188,6 +189,8 @@ class ServerSettings { Logger.info(`[ServerSettings] Using backup path from environment variable ${process.env.BACKUP_PATH}`) this.backupPath = process.env.BACKUP_PATH } + + this.backupPathEnvSet = !!settings.process.env.BACKUP_PATH || false } toJSON() { @@ -206,6 +209,7 @@ class ServerSettings { rateLimitLoginRequests: this.rateLimitLoginRequests, rateLimitLoginWindow: this.rateLimitLoginWindow, backupPath: this.backupPath, + backupPathEnvSet: this.backupPathEnvSet, backupSchedule: this.backupSchedule, backupsToKeep: this.backupsToKeep, maxBackupSize: this.maxBackupSize, From d46de541d6712246eef89cb18b6bbdc92ea14424 Mon Sep 17 00:00:00 2001 From: Nicholas Wallace Date: Fri, 5 Jul 2024 17:41:07 +0000 Subject: [PATCH 2/5] Fix: bad variable name --- 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 d5519c52..e5700a07 100644 --- a/server/objects/settings/ServerSettings.js +++ b/server/objects/settings/ServerSettings.js @@ -190,7 +190,7 @@ class ServerSettings { this.backupPath = process.env.BACKUP_PATH } - this.backupPathEnvSet = !!settings.process.env.BACKUP_PATH || false + this.backupPathEnvSet = !!process.env.BACKUP_PATH || false } toJSON() { From 4d24817ced6b30d52b38be2a27ff7191330dc189 Mon Sep 17 00:00:00 2001 From: Nicholas Wallace Date: Fri, 5 Jul 2024 17:44:49 +0000 Subject: [PATCH 3/5] Prevent editing backup path in web interface when env variable set --- client/pages/config/backups.vue | 10 +++++++--- client/strings/en-us.json | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/client/pages/config/backups.vue b/client/pages/config/backups.vue index dc14e4e1..578ae6bd 100644 --- a/client/pages/config/backups.vue +++ b/client/pages/config/backups.vue @@ -16,11 +16,11 @@
- - {{ $strings.ButtonSave }} + + {{ $strings.ButtonSave }} {{ $strings.ButtonCancel }} -

{{ $strings.MessageBackupsLocationEditNote }}

+

{{ canEditBackup ? $strings.MessageBackupsLocationEditNote : $strings.MessageBackupsLocationNoEditNote }}

@@ -115,6 +115,10 @@ export default { timeFormat() { return this.serverSettings.timeFormat }, + canEditBackup() { + // Prevent editing of backup path if an environement variable is set + return !this.serverSettings.backupPathEnvSet + }, scheduleDescription() { if (!this.cronExpression) return '' const parsed = this.$parseCronExpression(this.cronExpression) diff --git a/client/strings/en-us.json b/client/strings/en-us.json index 74064ad5..b9b9b5de 100644 --- a/client/strings/en-us.json +++ b/client/strings/en-us.json @@ -605,6 +605,7 @@ "MessageAppriseDescription": "To use this feature you will need to have an instance of Apprise API running or an api that will handle those same requests.
The Apprise API Url should be the full URL path to send the notification, e.g., if your API instance is served at http://192.168.1.1:8337 then you would put http://192.168.1.1:8337/notify.", "MessageBackupsDescription": "Backups include users, user progress, library item details, server settings, and images stored in /metadata/items & /metadata/authors. Backups do not include any files stored in your library folders.", "MessageBackupsLocationEditNote": "Note: Updating the backup location will not move or modify existing backups", + "MessageBackupsLocationNoEditNote": "Note: The backup location is set through an environment variable and cannot be changed here.", "MessageBackupsLocationPathEmpty": "Backup location path cannot be empty", "MessageBatchQuickMatchDescription": "Quick Match will attempt to add missing covers and metadata for the selected items. Enable the options below to allow Quick Match to overwrite existing covers and/or metadata.", "MessageBookshelfNoCollections": "You haven't made any collections yet", From a1688488e5d3ff324c9aa650b7caa252da53c58f Mon Sep 17 00:00:00 2001 From: Nicholas Wallace Date: Fri, 5 Jul 2024 17:58:42 +0000 Subject: [PATCH 4/5] Fix: name of `backupPathEnvSet` variable --- server/controllers/BackupController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/controllers/BackupController.js b/server/controllers/BackupController.js index 69eae30a..df33aa1d 100644 --- a/server/controllers/BackupController.js +++ b/server/controllers/BackupController.js @@ -11,7 +11,7 @@ class BackupController { res.json({ backups: this.backupManager.backups.map((b) => b.toJSON()), backupLocation: this.backupManager.backupPath, - backupEnvSet: this.backupManager.backupPathEnvSet + backupPathEnvSet: this.backupManager.backupPathEnvSet }) } From 7c0b4e35d758c46639a1dddd494d27423ec36caa Mon Sep 17 00:00:00 2001 From: advplyr Date: Fri, 5 Jul 2024 16:10:07 -0500 Subject: [PATCH 5/5] Update backups config page to use backupPathEnvSet returned from endpoint, remove from ServerConfig --- client/components/tables/BackupsTable.vue | 2 +- client/pages/config/backups.vue | 12 +++++++----- server/managers/BackupManager.js | 2 +- server/objects/settings/ServerSettings.js | 4 ---- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/client/components/tables/BackupsTable.vue b/client/components/tables/BackupsTable.vue index 380394bd..a8fbade6 100644 --- a/client/components/tables/BackupsTable.vue +++ b/client/components/tables/BackupsTable.vue @@ -171,7 +171,7 @@ export default { this.$axios .$get('/api/backups') .then((data) => { - this.$emit('loaded', data.backupLocation) + this.$emit('loaded', data) this.setBackups(data.backups || []) }) .catch((error) => { diff --git a/client/pages/config/backups.vue b/client/pages/config/backups.vue index 578ae6bd..7b64cbb2 100644 --- a/client/pages/config/backups.vue +++ b/client/pages/config/backups.vue @@ -92,6 +92,7 @@ export default { newServerSettings: {}, showCronBuilder: false, showEditBackupPath: false, + backupPathEnvSet: false, backupLocation: '', newBackupLocation: '', savingBackupPath: false @@ -116,8 +117,8 @@ export default { return this.serverSettings.timeFormat }, canEditBackup() { - // Prevent editing of backup path if an environement variable is set - return !this.serverSettings.backupPathEnvSet + // Prevent editing of backup path if an environment variable is set + return !this.backupPathEnvSet }, scheduleDescription() { if (!this.cronExpression) return '' @@ -131,9 +132,10 @@ export default { } }, methods: { - backupsLoaded(backupLocation) { - this.backupLocation = backupLocation - this.newBackupLocation = backupLocation + backupsLoaded(data) { + this.backupLocation = data.backupLocation + this.newBackupLocation = data.backupLocation + this.backupPathEnvSet = data.backupPathEnvSet }, cancelEditBackupPath() { this.newBackupLocation = this.backupLocation diff --git a/server/managers/BackupManager.js b/server/managers/BackupManager.js index ae79569c..88772c58 100644 --- a/server/managers/BackupManager.js +++ b/server/managers/BackupManager.js @@ -30,7 +30,7 @@ class BackupManager { } get backupPathEnvSet() { - return global.ServerSettings.backupPathEnvSet + return !!process.env.BACKUP_PATH } get backupSchedule() { diff --git a/server/objects/settings/ServerSettings.js b/server/objects/settings/ServerSettings.js index e5700a07..6ade11a9 100644 --- a/server/objects/settings/ServerSettings.js +++ b/server/objects/settings/ServerSettings.js @@ -26,7 +26,6 @@ class ServerSettings { this.rateLimitLoginWindow = 10 * 60 * 1000 // 10 Minutes // Backups - this.backupPathEnvSet = false this.backupPath = Path.join(global.MetadataPath, 'backups') this.backupSchedule = false // If false then auto-backups are disabled this.backupsToKeep = 2 @@ -189,8 +188,6 @@ class ServerSettings { Logger.info(`[ServerSettings] Using backup path from environment variable ${process.env.BACKUP_PATH}`) this.backupPath = process.env.BACKUP_PATH } - - this.backupPathEnvSet = !!process.env.BACKUP_PATH || false } toJSON() { @@ -209,7 +206,6 @@ class ServerSettings { rateLimitLoginRequests: this.rateLimitLoginRequests, rateLimitLoginWindow: this.rateLimitLoginWindow, backupPath: this.backupPath, - backupPathEnvSet: this.backupPathEnvSet, backupSchedule: this.backupSchedule, backupsToKeep: this.backupsToKeep, maxBackupSize: this.maxBackupSize,