feat(database): SQLite database backups (#1756)

* feat(database): SQLite database backups

* feat(database): do not produce SQL injections

* feat(database): retain all backups if 0 or less
refactor(database): specify database driver in func names

* refactor(database): return early on cleanup

* refactor(database): do not call cleanup func if max backups set to 0

* refactor(database): backup retention behavior

* feat(database): improve logging

---------

Co-authored-by: ze0s <43699394+zze0s@users.noreply.github.com>
This commit is contained in:
martylukyy 2024-11-12 19:14:45 +01:00 committed by GitHub
parent 1227657ae8
commit 74eea79215
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 146 additions and 12 deletions

View file

@ -86,6 +86,12 @@ checkForUpdates = true
#
sessionSecret = "{{ .sessionSecret }}"
# Database Max Backups
#
# Default: 5
#
#databaseMaxBackups = 5
# Golang pprof profiling and tracing
#
#profilingEnabled = false
@ -216,6 +222,7 @@ func (c *AppConfig) defaults() {
LogPath: "",
LogMaxSize: 50,
LogMaxBackups: 3,
DatabaseMaxBackups: 5,
BaseURL: "/",
SessionSecret: api.GenerateSecureToken(16),
CustomDefinitions: "",
@ -293,6 +300,13 @@ func (c *AppConfig) loadFromEnv() {
}
}
if v := os.Getenv(prefix + "DATABASE_MAX_BACKUPS"); v != "" {
i, _ := strconv.ParseInt(v, 10, 32)
if i > 0 {
c.Config.DatabaseMaxBackups = int(i)
}
}
if v := os.Getenv(prefix + "POSTGRES_HOST"); v != "" {
c.Config.PostgresHost = v
}