Preventing Time Machine ™ disk being ejected by a Apple Script that ejects disks?
I have an apple script to eject all network disks, but not any of the internal partitions I have.
Problem is that if TM is running when the script runs it also ejects the TM disk (this is on a remote server). This should not be so.
Below the script I use:
set exceptionsList to {"MobileBackups", "HD1", "HD2", "HD3", "HD4", "EFI", "Time Machine Backups"}
tell application "Finder"
set diskList to the disks
repeat with mountedDisk in diskList
if name of mountedDisk is not in exceptionsList then
eject mountedDisk
end if
end repeat
end tell
As you can see I have tried to use different names (MobileBackups", “HD1”, “EFI”, “Time Machine Backups”) for the TM disk to no avail.
Here is what I see for the TM disk if I run Disk Utility in Terminal, hence the names above.
/dev/disk5 (disk image): #: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme +450.0 GB disk5
1: EFI EFI 209.7 MB disk5s1
2: Apple_HFS Time Machine Backups 449.7 GB disk5s2
My question is how to prevent the TM disk from being ejected?
while TM is running there are two shared volumes, Time Machine Backups and the enclosing volume (below named as VolumeOfTimeMachineBackups)
You can filter all shared volumes with System Events, on a local volume the server property is missing value.
tell application "System Events"
set networkVolumes to name of disks whose name is not "Time Machine Backups" and name is not "VolumeOfTimeMachineBackups" and server is not missing value
end tell
tell application "Finder"
repeat with aVolume in networkVolumes
eject disk aVolume
end repeat
end tell
Could it have to do with the EFI Boot also being loaded? just a wild guess on my site.
I also tried:
tell application "System Events"
set networkVolumes to name of disks whose name is not "Time Machine Backups" and name is not "VolumeOfTimeMachineBackups" and server is not missing value
end tell
tell application "Finder"
repeat with aVolume in networkVolumes
eject disk aVolume
end repeat
end tell
What’s the name you gave to your TM disk?
Use that name in your exception list.
If that doesn’t work rename your TM disk to another name. And try again. The solution shouldn’t be hard to get. I guess you mess around with wild theories when the solution is at hand.
Don’t… Simply don’t use the Terminal. Why complicating things? Apart shell script you don’t need the Terminal. Here we code in Applescript dude! :lol:
Same here. According to System Events’s dictionary, the ‘server’ property only applies to AFP volumes, so if you’re using something else, all your disks’ ‘server’ values will be ‘missing value’. To filter for the names of non-local volumes, use:
tell application "System Events"
set networkVolumes to name of disks whose local volume is false
end tell
You could also try using ‘displayed name’ instead of ‘name’ to see if that produces anything more recognisable as your TM volume name.
If the returned list doesn’t contain a name you can easily associate with your TM disk, you should try working through it one name at a time, explicitly telling the Finder to eject the disk of that name and making a note of which name(s) cause the TM disk to be ejected. Hopefully that’ll get you a little closer to a solution.
Everyone here gave you useful info (I don’t mind my bit of info although it’s still a hint)
If your ideas aren’t clear or complete nobody can please you. Nothing is obvious.