From 63f6a9b085467dae9f90f59e3b32b57fdbada478 Mon Sep 17 00:00:00 2001 From: greatroar <61184462+greatroar@users.noreply.github.com> Date: Sun, 6 Feb 2022 17:43:22 +0100 Subject: [PATCH] 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. --- changelog/unreleased/issue-3641 | 13 +++++++++++++ cmd/restic/cmd_backup.go | 21 ++++++++++++--------- 2 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 changelog/unreleased/issue-3641 diff --git a/changelog/unreleased/issue-3641 b/changelog/unreleased/issue-3641 new file mode 100644 index 000000000..4474990d3 --- /dev/null +++ b/changelog/unreleased/issue-3641 @@ -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 diff --git a/cmd/restic/cmd_backup.go b/cmd/restic/cmd_backup.go index fe7da3333..873fce163 100644 --- a/cmd/restic/cmd_backup.go +++ b/cmd/restic/cmd_backup.go @@ -579,16 +579,19 @@ func runBackup(opts BackupOptions, gopts GlobalOptions, term *termstatus.Termina return err } - parentSnapshotID, err := findParentSnapshot(gopts.ctx, repo, opts, targets, timeStamp) - if err != nil { - return err - } + var parentSnapshotID *restic.ID + if !opts.Stdin { + parentSnapshotID, err = findParentSnapshot(gopts.ctx, repo, opts, targets, timeStamp) + if err != nil { + return err + } - if !gopts.JSON { - if parentSnapshotID != nil { - progressPrinter.P("using parent snapshot %v\n", parentSnapshotID.Str()) - } else { - progressPrinter.P("no parent snapshot found, will read all files\n") + if !gopts.JSON { + if parentSnapshotID != nil { + progressPrinter.P("using parent snapshot %v\n", parentSnapshotID.Str()) + } else { + progressPrinter.P("no parent snapshot found, will read all files\n") + } } }