backup: don't pretend to lock repo for dry run

The dry run did not actually create lock files, but still ran all other
parts of the lock processing.
This commit is contained in:
Michael Eischer 2023-06-17 20:06:42 +02:00
parent f490288738
commit 05e5e29a8c
1 changed files with 7 additions and 4 deletions

View File

@ -506,10 +506,13 @@ func runBackup(ctx context.Context, opts BackupOptions, gopts GlobalOptions, ter
if !gopts.JSON { if !gopts.JSON {
progressPrinter.V("lock repository") progressPrinter.V("lock repository")
} }
lock, ctx, err := lockRepo(ctx, repo, gopts.RetryLock, gopts.JSON) if !opts.DryRun {
defer unlockRepo(lock) var lock *restic.Lock
if err != nil { lock, ctx, err = lockRepo(ctx, repo, gopts.RetryLock, gopts.JSON)
return err defer unlockRepo(lock)
if err != nil {
return err
}
} }
// rejectByNameFuncs collect functions that can reject items from the backup based on path only // rejectByNameFuncs collect functions that can reject items from the backup based on path only