* wal_restore: use temporary file to prevent generating empty files when the
  transfer fails