I put work files in Git repositories and sync between computers/laptops using an external SSD. So for example if I want to sync repo1 from my PC to my laptop, these are the steps that are done:
- plug and mount external SSD on PC
- on PC:
cd /media/externalssd/repo1 && git pull ~/repo1 - unmount and unplug external SSD on PC
- plug and mount external SSD on laptop
- on laptop:
cd ~/repo1 && git pull /media/externalssd/repo1
Additional information: I'm using ZFS on Linux using zfs-fuse.
Sometimes, in the middle of the pull, the USB cable connection is not good so the filesystem is "disconnected" or sometimes zfs-fuse daemon dies. After I restart zfs-fuse and remount the filesystems, sometimes I will end up with a few files being truncated on the laptop and the repository on the laptop is no longer recognized as a git repo ("fatal: Not a git repository (or any parent up to mount point /blah)"). And sometimes, the repository on the SSD also gets corrupted.
This scares me.
Which element(s) probably truncate the files? The SSD? Linux? zfs-fuse? Git? How should I avoid this corruption and have a reliable sync process?