rsync on macOS copies "phantom data" when drive disconnects

Super User Asked by zyklus on December 2, 2020

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.

One Answer

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:

       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.

Correct answer by tbenz9 on December 2, 2020

Add your own answers!

Related Questions

Excel Copy and keep

2  Asked on December 11, 2021 by kyle-smith


issue in HDMI TO VGA conversion

3  Asked on December 9, 2021 by violet-kiwi


Alias for IPs in the home LAN network

3  Asked on December 9, 2021 by sanjihan


How can I organize files opened in notepad++ by project

2  Asked on December 9, 2021 by meridian


Strange HDDSCAN results, consecutive bad blocks

3  Asked on December 9, 2021 by ivan-zhoga


How to install Big Sur Beta on Parallels

0  Asked on December 9, 2021 by anoop-vaidya


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir