mirror of
https://github.com/go-vikunja/vikunja.git
synced 2026-02-01 22:47:40 +00:00
feat: add --preserve-config flag to restore command (#1939)
Add a new `--preserve-config` flag to the restore command that allows users to restore database and files from a dump while keeping their existing configuration file untouched.
This commit is contained in:
@@ -45,7 +45,7 @@ import (
|
||||
const maxConfigSize = 5 * 1024 * 1024 // 5 MB, should be largely enough
|
||||
|
||||
// Restore takes a zip file name and restores it
|
||||
func Restore(filename string) error {
|
||||
func Restore(filename string, overrideConfig bool) error {
|
||||
|
||||
r, err := zip.OpenReader(filename)
|
||||
if err != nil {
|
||||
@@ -101,9 +101,14 @@ func Restore(filename string) error {
|
||||
|
||||
///////
|
||||
// Restore the config file
|
||||
err = restoreConfig(configFile, dotEnvFile)
|
||||
if err != nil {
|
||||
return err
|
||||
if overrideConfig {
|
||||
err = restoreConfig(configFile, dotEnvFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
log.Warning("Preserving existing configuration (--preserve-config flag used)")
|
||||
log.Warning("Configuration preserved - ensure your current config is compatible with the restored data")
|
||||
}
|
||||
log.Info("Restoring...")
|
||||
|
||||
@@ -188,7 +193,9 @@ func Restore(filename string) error {
|
||||
///////
|
||||
// Done
|
||||
log.Infof("Done restoring dump.")
|
||||
log.Infof("Restart Vikunja to make sure the new configuration file is applied.")
|
||||
if overrideConfig {
|
||||
log.Infof("Restart Vikunja to make sure the new configuration file is applied.")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user