Compare commits

...

1 Commits

Author SHA1 Message Date
IamTheFij 9d1b9c68fd WIP: Automatically set restore target to `/` if all backup paths are absolute
continuous-integration/drone/push Build is failing Details
2023-10-25 20:01:37 -07:00
1 changed files with 18 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import (
"io/fs" "io/fs"
"log" "log"
"os" "os"
"path"
"strings" "strings"
) )
@ -405,6 +406,23 @@ func (t BackupFilesTask) RunRestore(cfg TaskConfig) error {
t.RestoreOpts = &RestoreOpts{} //nolint:exhaustruct 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 == "" { if t.snapshot == "" {
t.snapshot = "latest" t.snapshot = "latest"
} }