Thanks to Anton Khirnov for reporting the problem.
(cherry picked from commit b841841428f902225265e3b4bffa36f477c2a395)
---
 lib/bup/client.py   | 4 +++-
 lib/bup/cmd/midx.py | 5 ++++-
 lib/bup/hlinkdb.py  | 4 +++-
 lib/bup/index.py    | 2 ++
 4 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/lib/bup/client.py b/lib/bup/client.py
index bda49d79..621c8b6f 100644
--- a/lib/bup/client.py
+++ b/lib/bup/client.py
@@ -9,7 +9,7 @@ import socket
 from bup import git, ssh, vfs
 from bup.compat import environ, pending_raise
 from bup.helpers import (Conn, atomically_replaced_file, chunkyreader, debug1,
-                         debug2, linereader, lines_until_sentinel,
+                         debug2, fsync, linereader, lines_until_sentinel,
                          mkdirp, nullcontext_if_not, progress, qprogress, DemuxConn)
 from 
bup.io import path_msg
 from bup.vint import write_bvec
@@ -282,6 +282,8 @@ class Client:
                 count += len(b)
                 qprogress('Receiving index from server: %d/%d\r' % (count, n))
             progress('Receiving index from server: %d/%d, done.\n' % (count, n))
+            f.flush()
+            fsync(f.fileno())
             self.check_ok()
 
     def _make_objcache(self):
diff --git a/lib/bup/cmd/midx.py b/lib/bup/cmd/midx.py
index 947ade31..aadea8aa 100644
--- a/lib/bup/cmd/midx.py
+++ b/lib/bup/cmd/midx.py
@@ -5,7 +5,8 @@ import glob, os, math, resource, struct, sys
 
 from bup import options, git, midx, _helpers, xstat
 from bup.compat import ExitStack, argv_bytes, hexstr
-from bup.helpers import (Sha1, add_error, atomically_replaced_file, debug1, fdatasync,
+from bup.helpers import (Sha1, add_error, atomically_replaced_file, debug1,
+                         fdatasync, fsync,
                          log, mmap_readwrite, qprogress,
                          saved_errors, unlink)
 from 
bup.io import byte_stream, path_msg
@@ -169,6 +170,8 @@ def _do_midx(outdir, outfilename, infilenames, prefixstr,
                 count = merge_into(fmap, bits, total, inp)
             f.seek(0, os.SEEK_END)
             f.write(b'\0'.join(allfilenames))
+            f.flush()
+            fsync(f.fileno())
 
     # This is just for testing (if you enable this, don't clear inp above)
     # if 0:
diff --git a/lib/bup/hlinkdb.py b/lib/bup/hlinkdb.py
index f7e5d721..4f16da0a 100644
--- a/lib/bup/hlinkdb.py
+++ b/lib/bup/hlinkdb.py
@@ -2,7 +2,7 @@
 from contextlib import ExitStack
 import os, pickle
 
-from bup.helpers import atomically_replaced_file, unlink
+from bup.helpers import atomically_replaced_file, fsync, unlink
 
 
 def pickle_load(filename):
@@ -44,6 +44,8 @@ class HLinkDB:
                                                               buffering=65536)
                 with self._cleanup.enter_context(self._pending_save) as f:
                     pickle.dump(self._node_paths, f, 2)
+                    f.flush()
+                    fsync(f.fileno())
             else: # No data
                 self._cleanup.callback(lambda: unlink(self._filename))
             self._cleanup = self._cleanup.pop_all()
diff --git a/lib/bup/index.py b/lib/bup/index.py
index 448155f9..6788eec1 100644
--- a/lib/bup/index.py
+++ b/lib/bup/index.py
@@ -7,6 +7,7 @@ from bup._helpers import UINT_MAX, bytescmp
 from bup.compat import pending_raise
 from bup.helpers import (add_error,
                          atomically_replaced_file,
+                         fsync,
                          log, merge_iter, mmap_readwrite,
                          progress, qprogress, resolve_parent, slashappend)
 
@@ -588,6 +589,7 @@ class Writer:
                 self.pending_index.cancel()
             else:
                 self.flush()
+                fsync(self.f.fileno())
 
     def __del__(self):
         assert self.closed
-- 
2.47.2