WIP: Automatically set restore target to /
if all backup paths are absolute
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
a2823e09ad
commit
9d1b9c68fd
18
tasks.go
18
tasks.go
@ -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"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user