Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.5: Disable Spotlight during Time Machine backups System 10.5
I am using Time Machine with a Western Digital MyBook World, and had the hardest time getting it to make backups (even incremental ones of only a few megabytes) with reasonable speed. Apart from having to turn off any virus scanner, Spotlight tried to index the backup drive, which made it unbearably slow. I was not able to add the backup mount to the Privacy tab in the Spotlight System Preferences panel -- neither with the preferences pane, nor with any mdutil commands.

So I had to turn it off whenever I was doing the backup with this command:
launchctl unload /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
After the backup had finished, I then reloaded the daemon. If you want to use Spotlight and scheduled backups, this is not really practical. So I found a blunt force method that works to me.

First, a daemon runs a script every minute to check if a process with backupd (the Spotlight process) in its name is running. If it is, it stops the Spotlight process, then turns it back on when it no longer finds the backupd process. Here's the script:
#!/bin/sh

pn=`ps -e | grep backupd | wc -l`
flagfile="/full/path/to/some/flagfile"
if [ $pn -gt 1 ] ; then
  if [ ! -f $flagfile ] ; then
  launchctl unload /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
  date > $flagfile
  fi
fi
if [ $pn -eq 1 ] ; then
  if [ -f $flagfile ] ; then
  launchctl load /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
  rm -f $flagfile
  fi
fi
(I am not that good at shell scripts and have trouble with their if-test-then-&& syntax, so there may be a more compact method to replace the nested ifs.) Use chmod 755 on the shell script to make it executable, and save it somewhere safe.

The flagfile can be any valid and accessible path and it shows when this script has triggered the unloading of the indexing daemon. Omitting this would cause tons of com.appl....mds: Already loaded messages to be sent to the console. To make this work, write another daemon that calls this script every 60 seconds:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/
PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>com.acme.disablespotlightonbackup</string>
        <key>OnDemand</key>
        <true/>
        <key>ProgramArguments</key>
        <array>
                <string>/full/path/to/shell/script/created/above</string>
        </array>
        <key>StartCalendarInterval</key>
        <dict>
                <key>Munute</key>
                <integer>1</integer>
        </dict>
</dict>
</plist>
Save the plist to /Library » LaunchDaemons » com.acme.disablespotlightonbackup.plist. Also change its permissions with chmod 644, and use chown to set the ownership to root:admin, and then load it with sudo launchctl load /Library....backup.plist. You may want to change acme to your user name, although it's not strictly necessary. This works for me like a charm for me.

[robg adds: I haven't tested this one.]
    •    
  • Currently 2.14 / 5
  You rated: 5 / 5 (7 votes cast)
 
[25,091 views]  

10.5: Disable Spotlight during Time Machine backups | 14 comments | Create New Account
Click here to return to the '10.5: Disable Spotlight during Time Machine backups' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.5: Disable Spotlight during Time Machine backups
Authored by: rflorence on Oct 28, '08 08:31:34AM

Running a daemon every minute seems like overkill. Why not rename /System/Library/CoreServices/backupd and install a script in its place:

mdutil -i off /Volumes/backup
./new-name-of-backupd
mdutil -i on /Volumes/backup

That should turn off spotlight indexing immediately before backupd runs, and turn it back on when the backup is finished.



[ Reply to This | # ]
10.5: Disable Spotlight during Time Machine backups
Authored by: allanmarcus on Oct 28, '08 10:57:27AM

the fact that you cannot add the backup volume to the privacy list seems to me to be indicative of a problem. I have no problem adding my external drives to my privacy list.

I would start by deleting the .Spotlight folder on the external drive, then remount it then try to add it to the privacy pane. If that doesn't work, look for other hints.



[ Reply to This | # ]
10.5: Disable Spotlight during Time Machine backups
Authored by: osxpounder on Oct 30, '08 10:59:28AM

I agree; you should be able to add that volume to the list of excluded items in Spotlight's prefs. The fact that you can't do that may indicate an unrecognized problem on your system.

BTW, I've had a WD MyBook for about 6 months, and I've found it to be totally unreliable. The worse thing about it is that it disconnects abruptly, sometimes corrupting files when it does so. This has happened on 2 Macs, so far, using various FireWire cables. For the past 6 weeks or more, I haven't used it.

Also, I found it difficult to uninstall the WD auto-backup software tool that came with the drive, but an email to support eventually led me to the company that supports that backup tool, and they responded quickly and courteously with the steps to uninstall. Sadly, that didn't stop the MyBook from disconnecting.



[ Reply to This | # ]
10.5: Disable Spotlight during Time Machine backups
Authored by: Zeitkind on Oct 31, '08 07:00:05PM

I had the same problem with those drives - until I tried to constantly cool them with a fan - and problems were gone. I think those drives just overheat in those plastic shells, I can't recommend them at all.
I now use them only for short backups and put them back on the shelf afterwards..



[ Reply to This | # ]
10.5: Disable Spotlight during Time Machine backups
Authored by: Dr. T on Oct 28, '08 11:38:17AM

I agree with Allen Marcus that there probably is a Spotlight indexing problem. My preferred solution is to use TinkerTool System to disable Spotlight indexing of the backup volume and to remove all Spotlight data and preferences. If this does not work, then a repair utility such as DiskWarrior should be used on the backup drive.

Alternately, reformatting the backup drive would probably fix the problem. Spotlight indexing should be turned off as soon as the reformatted drive is mounted, and Time Machine may need to be relinked to the backup drive.



[ Reply to This | # ]
10.5: Disable Spotlight during Time Machine backups
Authored by: Philip Wing on Oct 28, '08 10:23:06PM

Unfortunately, I could be wrong, but backupd is the *Time Machine* process, not Spotlight. Used Activity Monitor to kill it, Time Machine failed.



[ Reply to This | # ]
10.5: Disable Spotlight during Time Machine backups
Authored by: lokon1979 on Oct 28, '08 10:25:24PM

spotlight indexing only do once, after that it works on the fly. sounds like a problem to me if the indexing ever create a, problem, to time machine.

the situation to most people should be, connect a fresh drive, spotlight finished index it in seconds before you can ever set up time machine. even you connect a drive with data, just wait till spotlight indexing the drive before setting up time machine should do the trick.

i think you should turn off time machine, add your drive to spotlight privacy list and remove it again so it will create a fresh new index. then at last turn back on time machine



[ Reply to This | # ]
10.5: Don't (?) Disable Spotlight during Time Machine backups
Authored by: drmacnut on Oct 28, '08 11:22:58PM

I have seen this problem twice on different Macs that I manage in our department. My guess is the Spotlight index of the backup was somehow damaged. My best solution so far has been to delete the TM backup sparseimage on the backup drive, reset TM (in Pref Pane) and do another complete backup. Since I have only seen this issue with Mac to Time Capsule backups, I have used direct-connect ethernet to run the new fresh backup, so it doesnʻt take forever to complete. Spotlight builds its database as the backup process, backupd, is running. And when you're done, you will not even notice Spotlight running while backups are being performed, nor will it slow them down. This is the normal (optimum) behaviour for TM and Spotlight together.

QUESTION: Is Spotlight not *required* by Time Machine in order for it to find files within the backup itself? Having no Spotlight index of the backup itself will nullify the utility of Time Machine right at its core, am I not right everyone?

Let's talk about this! There is a paucity of good information on the interaction of Spotlight and Time Machine it seems.

I think disabling Spotlight at the time backupd is running is like asking for trouble. Admittedly, having Spotlight try to either complete or create a new index at the same time as TM is trying to do a backup will cause both processes to seemingly never complete (quite honestly!) and a normally good running Mac can sometimes slow to a crawl. In your situation, there was obviously a problem and Spotlight was trying to get caught up again. But for you to stop Spotlight from running at all, I think, is probably dangerous.

I have also spent many hours pondering this issue and trying various fixes. At least I can say that without exception, resetting Time Machine, deleting the original backup sparseimage, and creating a brand new backup will solve the problem, and you will be back up and running again without a need for hacking, killing, or stamping upon Spotlight.



[ Reply to This | # ]
10.5: Don't (?) Disable Spotlight during Time Machine backups
Authored by: PizzaCake on Aug 30, '09 08:40:21AM

I'd also like to know what effect disabling spotlight has when running backupd?



[ Reply to This | # ]
10.5: Disable Spotlight during Time Machine backups
Authored by: by on Oct 29, '08 12:34:46AM

Albeit you apparently can't add the Backup Volume or TimeCapsule's SparseBundle Volume to the Privacy List of Spotlight via the '+' command, to me it worked very well to just drag the volume's icon to the Privacy window of Spotlight where it appears if not directly then at least the next time I open that very window.

Works like a charm for me with 10.5.5 and bot a PowerBook G4 and a MacBook Pro 15".

Best regards,
Michael



[ Reply to This | # ]
10.5: Disable Spotlight during Time Machine backups
Authored by: matzh on Nov 01, '08 07:25:16AM

Thanks for all the hints and comments.
Of those who got it back to work or who can add the backup volume to the privacy list, is anyone using this particular Backup Disk: "WD Mybook World Edition" with Firmware 02.00.18?
I had been trying for the longest time to fiddle with the .Spotlight-V100 directory of that drive, deleting it to have spotlight rebuild it, using the mdutil framework etc. It showed, in general, very odd behaviour in the sense that indexing could not be enabled or disabled.
I also cannot drack and drop it. It gives me an "unknown error" when I try.
@drmacnut: I can browse through my older backups without much problem. It takes some time, for particular dates to refresh in the finder window, but this is not surprising, as I have my Mybook now access the backup over the WLAN.
I will dry to check the disk image using the disk manager and by hooking up the computer to the ethernet, again. If there is something corrupted, I will post it here.



[ Reply to This | # ]
10.5: Disable Spotlight during Time Machine backups
Authored by: matzh on Nov 01, '08 01:14:24PM

Thanks for all the hints and comments.
Of those who got it back to work or who can add the backup volume to the privacy list, is anyone using this particular Backup Disk: "WD Mybook World Edition" with Firmware 02.00.18?
I had been trying for the longest time to fiddle with the .Spotlight-V100 directory of that drive, deleting it to have spotlight rebuild it, using the mdutil framework etc. It showed, in general, very odd behaviour in the sense that indexing could not be enabled or disabled.
I also cannot drack and drop it. It gives me an "unknown error" when I try.
@drmacnut: I can browse through my older backups without much problem. It takes some time, for particular dates to refresh in the finder window, but this is not surprising, as I have my Mybook now access the backup over the WLAN.
I will try to check the sparesbundle (although I did and it was o.k.). It will not let me check the mounted Backup Disk, though (The error is an invalid B-tree node and that means that the disk is in use, I think). If I get any results that allow me to leave spotlight turned on, I will post it here.



[ Reply to This | # ]
10.5: Disable Spotlight during Time Machine backups
Authored by: Johnny_B on Nov 30, '08 06:57:04AM
I used ACL to "disable" Spotlight. Spotlight will still try to index it, but will give up and fail after some seconds...
sudo su
cd /Volumes/Time_Machine/.Spotlight-V100/Store-V1/
rm -r Stores; mkdir Stores
chmod +a "everyone deny list,search,add_file,add_subdirectory" Stores
Works here...

[ Reply to This | # ]
10.5: Disable Spotlight during Time Machine backups
Authored by: PizzaCake on Dec 20, '09 07:42:31AM

starting up in safe mode (hold shift on startup) disables spotlight, since doing this I've had flawless time machine backups and also file transfers on usb-ide hard drives which otherwise disconnect randomly.



[ Reply to This | # ]