Backup failed with "unexpected end of JSON input"

I was running another phase of my overall initial backup to B2, but it failed with:

error while saving data to the repo: unexpected end of JSON input
Close
github.com/restic/restic/internal/backend/b2.(*b2Backend).Save
	src/github.com/restic/restic/internal/backend/b2/b2.go:242
github.com/restic/restic/internal/repository.(*Repository).savePacker
	src/github.com/restic/restic/internal/repository/packer_manager.go:122
github.com/restic/restic/internal/repository.(*Repository).SaveAndEncrypt
	src/github.com/restic/restic/internal/repository/repository.go:203
github.com/restic/restic/internal/repository.(*Repository).SaveBlob
	src/github.com/restic/restic/internal/repository/repository.go:529
github.com/restic/restic/internal/archiver.(*Archiver).Save
	src/github.com/restic/restic/internal/archiver/archiver.go:104
github.com/restic/restic/internal/archiver.(*Archiver).saveChunk
	src/github.com/restic/restic/internal/archiver/archiver.go:161
runtime.goexit
	/usr/lib/go/src/runtime/asm_amd64.s:2337
panic: Close: unexpected end of JSON input

goroutine 96870 [running]:
github.com/restic/restic/internal/archiver.(*Archiver).saveChunk(0xc4201cb270, 0xe01020, 0xc4200140b0, 0x222daa2f, 0x43a880, 0x1ad88469600000, 0xc442bbc000, 0x43a880, 0x92a000, 0xc420088c60, ...)
	src/github.com/restic/restic/internal/archiver/archiver.go:166 +0x41b
created by github.com/restic/restic/internal/archiver.(*Archiver).SaveFile
	src/github.com/restic/restic/internal/archiver/archiver.go:240 +0x3d0

The command I ran for the backup was:

restic -o b2.connections=32 -r b2:redacted:redacted backup --force <files…>

While I haven’t seen this particular error before I highly suspect that it is a malformed reply from the B2 API. At least the place in the code where it fails is when the response from the B2 server is parsed.

Just retry the backup.

1 Like