diff --git a/cmd/restic/cmd_backup.go b/cmd/restic/cmd_backup.go index c377c5cad..a20c4ebc7 100644 --- a/cmd/restic/cmd_backup.go +++ b/cmd/restic/cmd_backup.go @@ -220,6 +220,12 @@ func (cmd CmdBackup) Execute(args []string) error { return err } + lock, err := restic.NewLock(repo) + defer lock.Unlock() + if err != nil { + return err + } + err = repo.LoadIndex() if err != nil { return err diff --git a/cmd/restic/cmd_cache.go b/cmd/restic/cmd_cache.go index 011fb3e23..de0efddb1 100644 --- a/cmd/restic/cmd_cache.go +++ b/cmd/restic/cmd_cache.go @@ -34,6 +34,12 @@ func (cmd CmdCache) Execute(args []string) error { return err } + lock, err := restic.NewLock(repo) + defer lock.Unlock() + if err != nil { + return err + } + cache, err := restic.NewCache(repo, cmd.global.CacheDir) if err != nil { return err diff --git a/cmd/restic/cmd_cat.go b/cmd/restic/cmd_cat.go index fc4ebc721..36b4aa49a 100644 --- a/cmd/restic/cmd_cat.go +++ b/cmd/restic/cmd_cat.go @@ -42,6 +42,12 @@ func (cmd CmdCat) Execute(args []string) error { return err } + lock, err := restic.NewLock(repo) + defer lock.Unlock() + if err != nil { + return err + } + tpe := args[0] var id backend.ID diff --git a/cmd/restic/cmd_dump.go b/cmd/restic/cmd_dump.go index b80e61509..e0c4ea702 100644 --- a/cmd/restic/cmd_dump.go +++ b/cmd/restic/cmd_dump.go @@ -109,6 +109,12 @@ func (cmd CmdDump) Execute(args []string) error { return err } + lock, err := restic.NewLock(repo) + defer lock.Unlock() + if err != nil { + return err + } + err = repo.LoadIndex() if err != nil { return err diff --git a/cmd/restic/cmd_find.go b/cmd/restic/cmd_find.go index 103e70cbd..4e28e2041 100644 --- a/cmd/restic/cmd_find.go +++ b/cmd/restic/cmd_find.go @@ -162,6 +162,12 @@ func (c CmdFind) Execute(args []string) error { return err } + lock, err := restic.NewLock(repo) + defer lock.Unlock() + if err != nil { + return err + } + c.pattern = args[0] if c.Snapshot != "" { diff --git a/cmd/restic/cmd_fsck.go b/cmd/restic/cmd_fsck.go index 6b8a8e1c6..76e0a1f8b 100644 --- a/cmd/restic/cmd_fsck.go +++ b/cmd/restic/cmd_fsck.go @@ -195,6 +195,12 @@ func (cmd CmdFsck) Execute(args []string) error { return err } + lock, err := restic.NewExclusiveLock(repo) + defer lock.Unlock() + if err != nil { + return err + } + err = repo.LoadIndex() if err != nil { return err diff --git a/cmd/restic/cmd_key.go b/cmd/restic/cmd_key.go index 19d73c4f6..47f5333c4 100644 --- a/cmd/restic/cmd_key.go +++ b/cmd/restic/cmd_key.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" + "github.com/restic/restic" "github.com/restic/restic/backend" "github.com/restic/restic/repository" ) @@ -121,6 +122,12 @@ func (cmd CmdKey) Execute(args []string) error { return err } + lock, err := restic.NewExclusiveLock(repo) + defer lock.Unlock() + if err != nil { + return err + } + switch args[0] { case "list": return cmd.listKeys(repo) diff --git a/cmd/restic/cmd_list.go b/cmd/restic/cmd_list.go index 95fe68db6..dda14aca7 100644 --- a/cmd/restic/cmd_list.go +++ b/cmd/restic/cmd_list.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" + "github.com/restic/restic" "github.com/restic/restic/backend" ) @@ -35,6 +36,12 @@ func (cmd CmdList) Execute(args []string) error { return err } + lock, err := restic.NewLock(repo) + defer lock.Unlock() + if err != nil { + return err + } + var t backend.Type switch args[0] { case "blobs": diff --git a/cmd/restic/cmd_restore.go b/cmd/restic/cmd_restore.go index f70d2fc6a..e2e7344a8 100644 --- a/cmd/restic/cmd_restore.go +++ b/cmd/restic/cmd_restore.go @@ -35,6 +35,12 @@ func (cmd CmdRestore) Execute(args []string) error { return err } + lock, err := restic.NewLock(repo) + defer lock.Unlock() + if err != nil { + return err + } + err = repo.LoadIndex() if err != nil { return err diff --git a/cmd/restic/cmd_snapshots.go b/cmd/restic/cmd_snapshots.go index 2ffb1d8b1..1947ed476 100644 --- a/cmd/restic/cmd_snapshots.go +++ b/cmd/restic/cmd_snapshots.go @@ -99,6 +99,12 @@ func (cmd CmdSnapshots) Execute(args []string) error { return err } + lock, err := restic.NewLock(repo) + defer lock.Unlock() + if err != nil { + return err + } + tab := NewTable() tab.Header = fmt.Sprintf("%-8s %-19s %-10s %s", "ID", "Date", "Source", "Directory") tab.RowFormat = "%-8s %-19s %-10s %s"