diff --git a/internal/backend/local/local.go b/internal/backend/local/local.go index be332e8ad..d6bdef1e4 100644 --- a/internal/backend/local/local.go +++ b/internal/backend/local/local.go @@ -148,6 +148,13 @@ func (b *Local) Save(_ context.Context, h restic.Handle, rd restic.RewindReader) } }(f) + // preallocate disk space + if size := rd.Length(); size > 0 { + if err := fs.PreallocateFile(f, size); err != nil { + debug.Log("Failed to preallocate %v with size %v: %v", finalname, size, err) + } + } + // save data, then sync wbytes, err := io.Copy(f, rd) if err != nil {