diff --git a/tasks.go b/tasks.go index 496c63f..03fd757 100644 --- a/tasks.go +++ b/tasks.go @@ -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" }