I’m having problems with my backup script. Normally I copy some files to an external Firewire disk as a backup procedure but I’m getting errors like “file is in use” ( MacOS X 10.4.4 ) even file are locked in the Trash. I want to disable Spotlight during the copy procedure because it seems the origin of the problem: when I copy a big folder with a lot of files, indexing starts and locks things.
What I have done is gone to the spotlight preference pane and in the Privacy pane, excluded my backup firewire drive so Spotlight won’t jump on it right away when I mount it. That seems to have cleared up a similar problem for me.
This could be a solution but I’ve found a more clever way: just disabling Spotlight indexing during the backup process:
(…)
set chkstat to the state of button “chkspot” of window “bmain” as boolean
if chkstat is true then
my write_info(“Deactivating Spotlight indexing…”)
try
do shell script “for slvolume in /Volumes/*; do /usr/bin/mdutil -i off ${slvolume}; done” with administrator privileges
on error
my write_info(“ERROR trying to deactivate Spotlight indexing…”)
end try
end if
(…)
After the copy process finishes, I reactivate Spotlight indexing.
There is a graphic interface for my backup script which contains a checkbox that allows to disable Spotlight using the previous code. You can forget the ‘if’ part, just the shell script is interesting to disable Spotlight indexing. Also replace ‘off’ by ‘on’ and you will have the enabling code.