How macOS Can Cause Data Loss: Spotlight Chooses on Backup (Clone) Volumes, Which User then Works on... Later Wiped Out by Backup
Yesterday I was writing some server code, but I had to run out for an errand. So I started a clone backup and left.
When I returned, I found my code was gone. I was baffled... what the hell happened?
It turns out that I had added a new backup drive, that macOS Spotlight had indexed that backup, and when I opened my source code files, Spotlight decided that instead of using the volume on which my original code resided, Spotlight would just willy-nilly show me files off the backup drive. So I had been editing my code on the backup drive.
The backup I had started had promptly wiped out all my work.
I’ve long loathed the “index by default” approach of Spotlight. Now I have a serious reason to dislike it—and this is not the first time I have suffered—today I spent half an hour debugging code... once again that was on my backup drive and therefore not compiling. Once I figured that out, I took the backup drives out of the Spotlight indexing but the damage had been done yet again (this time, my wasted time).
I don’t know any foolproof way to not encounter this nasty bug yet again—it’s a manual operation to remember to exclude a volume when adding or erasing one. A shell script using mdutil would work, if/whenI get time to do that.