WIP: Automatically set restore target to `/` if all backup paths are absolute
continuous-integration/drone/push Build is failing Details

This commit is contained in:
IamTheFij 2023-10-25 20:01:37 -07:00
parent a2823e09ad
commit 9d1b9c68fd
1 changed files with 18 additions and 0 deletions

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"
}