1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-22 15:57:07 +00:00

restore: forbid --target / --delete unless include/exclude is specified

This commit is contained in:
Michael Eischer 2024-07-07 13:54:45 +02:00
parent be98402ac6
commit 1856f4d87a

View file

@ -2,6 +2,7 @@ package main
import (
"context"
"path/filepath"
"time"
"github.com/restic/restic/internal/debug"
@ -107,6 +108,10 @@ func runRestore(ctx context.Context, opts RestoreOptions, gopts GlobalOptions,
return errors.Fatal("--dry-run and --verify are mutually exclusive")
}
if opts.Delete && filepath.Clean(opts.Target) == "/" && !hasExcludes && !hasIncludes {
return errors.Fatal("'--target / --delete' must be combined with an include or exclude filter")
}
snapshotIDString := args[0]
debug.Log("restore %v to %v", snapshotIDString, opts.Target)