Compare commits

...

1 Commits

Author SHA1 Message Date
9d1b9c68fd WIP: Automatically set restore target to / if all backup paths are absolute
Some checks failed
continuous-integration/drone/push Build is failing
2023-10-25 20:01:37 -07:00

View File

@ -6,6 +6,7 @@ import (
"io/fs"
"log"
"os"
"path"
"strings"
)
@ -405,6 +406,23 @@ func (t BackupFilesTask) RunRestore(cfg TaskConfig) error {
t.RestoreOpts = &RestoreOpts{} //nolint:exhaustruct
}
// If all backup paths are absolute and target is empty, use root as the restore target
if t.RestoreOpts.Target == "" {
allAbs := true
for _, backupPath := range t.Paths {
if !path.IsAbs(backupPath) {
allAbs = false
break
}
}
if allAbs {
t.RestoreOpts.Target = "/"
}
}
if t.snapshot == "" {
t.snapshot = "latest"
}