mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-03 20:49:04 +01:00
Merge pull request #489 from selfhost-alt/configurable-backup-size
Make maximum backup size configurable
This commit is contained in:
commit
c5a9c2bf5a
@ -20,6 +20,14 @@
|
|||||||
<p class="pl-4 text-lg">Number of backups to keep</p>
|
<p class="pl-4 text-lg">Number of backups to keep</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-center py-2">
|
||||||
|
<ui-text-input type="number" v-model="maxBackupSize" no-spinner :disabled="updatingServerSettings" :padding-x="1" text-center class="w-10" @change="updateBackupsSettings" />
|
||||||
|
|
||||||
|
<ui-tooltip :text="maxBackupSizeTooltip">
|
||||||
|
<p class="pl-4 text-lg">Maximum backup size (in GB) <span class="material-icons icon-text">info_outlined</span></p>
|
||||||
|
</ui-tooltip>
|
||||||
|
</div>
|
||||||
|
|
||||||
<tables-backups-table />
|
<tables-backups-table />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -32,6 +40,7 @@ export default {
|
|||||||
updatingServerSettings: false,
|
updatingServerSettings: false,
|
||||||
dailyBackups: true,
|
dailyBackups: true,
|
||||||
backupsToKeep: 2,
|
backupsToKeep: 2,
|
||||||
|
maxBackupSize: 1,
|
||||||
newServerSettings: {}
|
newServerSettings: {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -47,19 +56,27 @@ export default {
|
|||||||
dailyBackupsTooltip() {
|
dailyBackupsTooltip() {
|
||||||
return 'Runs at 1am every day (your server time). Saved in /metadata/backups.'
|
return 'Runs at 1am every day (your server time). Saved in /metadata/backups.'
|
||||||
},
|
},
|
||||||
|
maxBackupSizeTooltip() {
|
||||||
|
return 'As a safeguard against misconfiguration, backups will fail if they exceed the configured size.'
|
||||||
|
},
|
||||||
serverSettings() {
|
serverSettings() {
|
||||||
return this.$store.state.serverSettings
|
return this.$store.state.serverSettings
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
updateBackupsSettings() {
|
updateBackupsSettings() {
|
||||||
|
if (isNaN(this.maxBackupSize) || this.maxBackupSize <= 0) {
|
||||||
|
this.$toast.error('Invalid maximum backup size')
|
||||||
|
return
|
||||||
|
}
|
||||||
if (isNaN(this.backupsToKeep) || this.backupsToKeep <= 0 || this.backupsToKeep > 99) {
|
if (isNaN(this.backupsToKeep) || this.backupsToKeep <= 0 || this.backupsToKeep > 99) {
|
||||||
this.$toast.error('Invalid number of backups to keep')
|
this.$toast.error('Invalid number of backups to keep')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var updatePayload = {
|
var updatePayload = {
|
||||||
backupSchedule: this.dailyBackups ? '0 1 * * *' : false,
|
backupSchedule: this.dailyBackups ? '0 1 * * *' : false,
|
||||||
backupsToKeep: Number(this.backupsToKeep)
|
backupsToKeep: Number(this.backupsToKeep),
|
||||||
|
maxBackupSize: Number(this.maxBackupSize)
|
||||||
}
|
}
|
||||||
this.updateServerSettings(updatePayload)
|
this.updateServerSettings(updatePayload)
|
||||||
},
|
},
|
||||||
@ -81,6 +98,7 @@ export default {
|
|||||||
|
|
||||||
this.backupsToKeep = this.newServerSettings.backupsToKeep || 2
|
this.backupsToKeep = this.newServerSettings.backupsToKeep || 2
|
||||||
this.dailyBackups = !!this.newServerSettings.backupSchedule
|
this.dailyBackups = !!this.newServerSettings.backupSchedule
|
||||||
|
this.maxBackupSize = this.newServerSettings.maxBackupSize || 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
@ -23,9 +23,6 @@ class BackupManager {
|
|||||||
this.scheduleTask = null
|
this.scheduleTask = null
|
||||||
|
|
||||||
this.backups = []
|
this.backups = []
|
||||||
|
|
||||||
// If backup exceeds this value it will be aborted
|
|
||||||
this.MaxBytesBeforeAbort = 1000000000 // ~ 1GB
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get serverSettings() {
|
get serverSettings() {
|
||||||
@ -263,7 +260,8 @@ class BackupManager {
|
|||||||
reject(err)
|
reject(err)
|
||||||
})
|
})
|
||||||
archive.on('progress', ({ fs: fsobj }) => {
|
archive.on('progress', ({ fs: fsobj }) => {
|
||||||
if (fsobj.processedBytes > this.MaxBytesBeforeAbort) {
|
const maxBackupSizeInBytes = this.serverSettings.maxBackupSize * 1000 * 1000 * 1000
|
||||||
|
if (fsobj.processedBytes > maxBackupSizeInBytes) {
|
||||||
Logger.error(`[BackupManager] Archiver is too large - aborting to prevent endless loop, Bytes Processed: ${fsobj.processedBytes}`)
|
Logger.error(`[BackupManager] Archiver is too large - aborting to prevent endless loop, Bytes Processed: ${fsobj.processedBytes}`)
|
||||||
archive.abort()
|
archive.abort()
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -29,6 +29,7 @@ class ServerSettings {
|
|||||||
// this.backupSchedule = '0 1 * * *' // If false then auto-backups are disabled (default every day at 1am)
|
// this.backupSchedule = '0 1 * * *' // If false then auto-backups are disabled (default every day at 1am)
|
||||||
this.backupSchedule = false
|
this.backupSchedule = false
|
||||||
this.backupsToKeep = 2
|
this.backupsToKeep = 2
|
||||||
|
this.maxBackupSize = 1
|
||||||
this.backupMetadataCovers = true
|
this.backupMetadataCovers = true
|
||||||
|
|
||||||
// Logger
|
// Logger
|
||||||
@ -78,6 +79,7 @@ class ServerSettings {
|
|||||||
|
|
||||||
this.backupSchedule = settings.backupSchedule || false
|
this.backupSchedule = settings.backupSchedule || false
|
||||||
this.backupsToKeep = settings.backupsToKeep || 2
|
this.backupsToKeep = settings.backupsToKeep || 2
|
||||||
|
this.maxBackupSize = settings.maxBackupSize || 1
|
||||||
this.backupMetadataCovers = settings.backupMetadataCovers !== false
|
this.backupMetadataCovers = settings.backupMetadataCovers !== false
|
||||||
|
|
||||||
this.loggerDailyLogsToKeep = settings.loggerDailyLogsToKeep || 7
|
this.loggerDailyLogsToKeep = settings.loggerDailyLogsToKeep || 7
|
||||||
@ -114,6 +116,7 @@ class ServerSettings {
|
|||||||
rateLimitLoginWindow: this.rateLimitLoginWindow,
|
rateLimitLoginWindow: this.rateLimitLoginWindow,
|
||||||
backupSchedule: this.backupSchedule,
|
backupSchedule: this.backupSchedule,
|
||||||
backupsToKeep: this.backupsToKeep,
|
backupsToKeep: this.backupsToKeep,
|
||||||
|
maxBackupSize: this.maxBackupSize,
|
||||||
backupMetadataCovers: this.backupMetadataCovers,
|
backupMetadataCovers: this.backupMetadataCovers,
|
||||||
loggerDailyLogsToKeep: this.loggerDailyLogsToKeep,
|
loggerDailyLogsToKeep: this.loggerDailyLogsToKeep,
|
||||||
loggerScannerLogsToKeep: this.loggerScannerLogsToKeep,
|
loggerScannerLogsToKeep: this.loggerScannerLogsToKeep,
|
||||||
|
Loading…
Reference in New Issue
Block a user