0

I'm trying to copy files off of a drive that is failing. It hasn't failed yet :)

Basically it keeps disconnecting every 30 seconds. macOS then automatically remounts it, but Finder is having issues copying files.

So I'm trying to use rsync -a --progress, but every time the drive disconnects rsync just "keeps going", and fills the rest of the file with… I dunno, something. I'd assume it'd write zeros, but it's writing actual data according to hexdump. In any case, it's not accurate data.

I've been able to reproduce the behavior by rsync'ing from a random SD card. If I pull the card while copying a 4gb file rsync just zips through and writes a full 4GB file, even though that's nonsense.

How do I get rsync to stop copying phantom data when a drive is disconnected??

The problem is that in 2020, macOS ships with a version of rsync from 2006.

1 Answer 1

2

Rsync should exit if the destination drive gets disconnected. You may need to specify a shorter timeout (in seconds) for this behavior to work properly if the drive is reconnecting quickly.

Something like rsync -a --progress --timeout 2

Relevant man info:

--timeout=TIMEOUT
       This  option  allows you to set a maximum I/O timeout in seconds. If no data is transferred for the specified time then rsync will exit. The default is 0, which means no timeout.
6
  • It doesn't, try it. rsync -a --progress external_path local_path, pull the drive while copying (use something unimportant obviously), rsync will fill the local file with whatever the external file size is, and at a much much faster rate than it was copying at initially
    – None
    Oct 11, 2020 at 21:31
  • I did try it, when I remove my sd card in the middle of an rsync copy using the exact command you mentioned, rsync exits with an error. rsync: write failed on "/media/tbenz9/4488-170B/data/ConfAvatar/conf_avatar_aec533a0e2fb23033990a1d2821bd225_101": Input/output error (5) rsync error: error in file IO (code 11) at receiver.c(374) [receiver=3.1.3]
    – tbenz9
    Oct 11, 2020 at 21:57
  • wtf? osx? rsync version? I'm on 2.6.9. That would be much better behavior than what I'm seeing, lol
    – None
    Oct 11, 2020 at 22:11
  • Tested with version 3.1.3 on Ubuntu 20.04, but I'm pretty certain my behavior is the expected behavior regardless of OS or rsync version.
    – tbenz9
    Oct 12, 2020 at 0:47
  • 1
    ... 2.6.9 was released in 2006. I just updated with homebrew and it works. Apple is shipping 14 year old software that has tons of updates available... gah. Thanks for your assistance!
    – None
    Oct 12, 2020 at 1:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .