Add a few locks to prevent data races

1 job for v2 in 37 seconds (queued for 1 second)
Status Job ID Name Coverage
  Test
failed #9116
test

00:00:37

 
Name Stage Failure
failed
test Test
2019/06/18 11:48:12 sh: restic -r /tmp/592476710/repo --password-file /tmp/restic-pw-098978637 snapshots --json --tag backup_id=34a84c5706b5f9b252aa629ac9e4a280 --tag f1
2019/06/18 11:48:13 sh: (restic -r /tmp/592476710/repo --password-file /tmp/restic-pw-098978637 restore --target /tmp 37a9f36a 1>&2 && cat /tmp/STDIN_source1_f1) | lz4c -d - - | (read row ; test "x$row" = xdata)
/bin/sh: 1: lz4c: not found
restoring <Snapshot 37a9f36a of [/STDIN_source1_f1] at 2019-06-18 11:48:10.880872632 +0000 UTC by @runner-3cef6525-project-359-concurrent-0> to /tmp
--- FAIL: TestRestic_Stream_Compress (5.07s)
repository_restic_test.go:125: Restore exit status 1
FAIL
FAIL git.autistici.org/ai3/tools/tabacco 16.222s
ERROR: Job failed: exit code 1