Don't set a parent for --stdin backups

Loading any parent tree for these only wastes time and memory.
Fixes #3641, where it was shown that the most recent tree will get
picked.

--parent is now implicitly ignored when --stdin is given.
This commit is contained in:
greatroar 2022-02-06 17:43:22 +01:00
parent 58236ead12
commit 63f6a9b085
2 changed files with 25 additions and 9 deletions

View file

@ -0,0 +1,13 @@
Change: Backups from stdin no longer have a parent
Snapshots made with `restic backup --stdin` no longer have a parent snapshot.
Since parent snapshots are only used to skip files in the scanning phase
based on filename and timestamps, the parent snapshot of a `--stdin` snapshot
was meaningless to begin with. Not setting a parent allows `restic backup`
to skip some startup operations.
The `--parent` option is still available for `restic backup --stdin`,
but is now ignored.
https://github.com/restic/restic/issues/3641
https://github.com/restic/restic/pull/3645

View file

@ -579,16 +579,19 @@ func runBackup(opts BackupOptions, gopts GlobalOptions, term *termstatus.Termina
return err return err
} }
parentSnapshotID, err := findParentSnapshot(gopts.ctx, repo, opts, targets, timeStamp) var parentSnapshotID *restic.ID
if err != nil { if !opts.Stdin {
return err parentSnapshotID, err = findParentSnapshot(gopts.ctx, repo, opts, targets, timeStamp)
} if err != nil {
return err
}
if !gopts.JSON { if !gopts.JSON {
if parentSnapshotID != nil { if parentSnapshotID != nil {
progressPrinter.P("using parent snapshot %v\n", parentSnapshotID.Str()) progressPrinter.P("using parent snapshot %v\n", parentSnapshotID.Str())
} else { } else {
progressPrinter.P("no parent snapshot found, will read all files\n") progressPrinter.P("no parent snapshot found, will read all files\n")
}
} }
} }