diff --git a/changelog/unreleased/issue-3518 b/changelog/unreleased/issue-3518 new file mode 100644 index 000000000..5a8edc4ea --- /dev/null +++ b/changelog/unreleased/issue-3518 @@ -0,0 +1,9 @@ +Bugfix: Make copy command honor `--no-lock` for source repository + +When passing the `--no-lock` flag to the copy command, restic still attempted +to lock the source repository, causing failures on read-only storage backends. +`--no-lock` is now respected and copy then no longer creates a lock in the +source repository. + +https://github.com/restic/restic/issues/3518 +https://github.com/restic/restic/pull/3589 diff --git a/cmd/restic/cmd_copy.go b/cmd/restic/cmd_copy.go index d16cd1742..030abc37d 100644 --- a/cmd/restic/cmd_copy.go +++ b/cmd/restic/cmd_copy.go @@ -73,10 +73,12 @@ func runCopy(opts CopyOptions, gopts GlobalOptions, args []string) error { return err } - srcLock, err := lockRepo(ctx, srcRepo) - defer unlockRepo(srcLock) - if err != nil { - return err + if !gopts.NoLock { + srcLock, err := lockRepo(ctx, srcRepo) + defer unlockRepo(srcLock) + if err != nil { + return err + } } dstLock, err := lockRepo(ctx, dstRepo)