View Full Version : How to stop updatedb from indexing backup drive?

08-14-2006, 10:49 AM
Has anyone figured out how to stop locate.updatedb from indexing one's backup drive? Currently /usr/bin/locate doubles its results, once from Macintosh HD and once from Backup HD. I already have Backup HD blocked from indexing by Spotlight, but that doesn't seem to affect locate.

A quick search gives this MacOSXhint, "Prevent locate's update from updating certain folders (http://www.macosxhints.com/article.php?story=20040706191520772)," but that refers to locate.updatedb running as a cron job, which it no longer does, so I'm reluctant to apply the hint. It also looks muy complicated. :o

If no one can help me out, I'll post whatever answer I come up with -- eventually.

08-14-2006, 06:32 PM
OK. It looks like locate.updatedb isn't fully implemented in OSX. It doesn't pay attention to options about excluding paths from indexing.

Here's another MacOShint that's more on target: Make the locate command ignore certain directories (http://www.macosxhints.com/article.php?story=20031106144210522). What I tried first is $ sudo /usr/libexec/locate.updatedb ---prunepaths=/Volumes/Backup\ HD/ It doesn't make any difference.

I then found a thread on MacOSX.com suggesting that OSX doesn't pay attention to prunepaths, locate.updatedb's options not working (http://macosx.com/forums/showthread.php?t=27785&highlight=updatedb). (Scroll down to cilly's post.)

I'm left with editing Apple's locate.updatedb script, which I'm not willing to do, or living with long results from locate queries. There is another possibility:

Does anyone know what the alias would look like (in my .bashrc) to redefine 'locate' to filter out /Volume/Backup\ HD? Something with grep?

I suppose I could also backup to a sparseimage in Backup HD.

08-14-2006, 07:47 PM
Are you trying to prevent multiple entries in Open With? Because that's not done with locate... it's done with LaunchServices.

08-14-2006, 07:55 PM
No, I'm trying to prevent the shell command 'locate' from returning two entries for every match, one from Macintosh HD and another from Backup HD. It's really a MacOSX or Unix question. Its relation to SuperDuper! is that the only reason I have backup drive is because of your excellent program.

I've figured out the command sequence to filter out the results in the backup drive locate SOMESTRING | grep -vw \/Volumes\/Backup\ HD Now I just have to figure out how to write the shell function in .bashrc so it sticks.

08-14-2006, 08:00 PM
Just wanted to make sure...

08-14-2006, 08:38 PM
Whew! Here's the line to add to .bashrc to redefine 'locate' so it excludes everything on the backup drive: # Exclude the backup drive from locate's results
function locate() { command locate $1 | grep -vw \/Volumes\/Backup\ HD; echo " ***REM: I redefined locate to exclude Backup HD***"; }
Of course the 'echo' part isn't required. I want it there in case something goes wrong with my custom 'locate,' so I won't forget that I had customized it.

I'm not quite sure if it should be '$1', '$*' or '$@'. '$1' seemed safest.