Improve database restore I/O robustness

This fixes an awesome bug where restoring from a pipe would not work,
because that's the case where you're going to see short Read()s.
4 jobs for master in 1 minute and 23 seconds (queued for 2 seconds)
Status Job ID Name Coverage
  Test
passed #1388
run_tests

00:00:22

 
  Build Src
passed #1389
build:src

00:00:13

 
  Build Pkg
passed #1390
build:pkg

00:00:31

 
  Upload
passed #1391
upload:pkg

00:00:15