Wednesday, February 20, 2019

#1 2019-01-26 03:20:46 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 220

Preventing TM disk being ejected by a Apple Script that ejects disks

Preventing Time Machine (TM) 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:

Applescript:

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?

Thanks.


Filed under: time machine, eject disk

Offline

 

#2 2019-01-26 06:42:31 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11550
Website

Re: Preventing TM disk being ejected by a Apple Script that ejects disks

Hi,

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.

Applescript:

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


regards

Stefan

Offline

 

#3 2019-01-26 07:49:29 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 220

Re: Preventing TM disk being ejected by a Apple Script that ejects disks

Thanks.  Does not work though.  It still ejects the TM disk. 


https://ibb.co/YDBtPzt

Offline

 

#4 2019-01-26 08:01:30 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11550
Website

Re: Preventing TM disk being ejected by a Apple Script that ejects disks

I tested the script.

On my machine it filters the TM volume reliably in the System Events line. Does the volume name contains special whitespace characters?


regards

Stefan

Offline

 

#5 2019-01-26 08:33:49 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 220

Re: Preventing TM disk being ejected by a Apple Script that ejects disks

as I said this is what I see in Terminal

/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

Should I look somewhere else to see the name it might use?

Offline

 

#6 2019-01-26 01:44:05 pm

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11550
Website

Re: Preventing TM disk being ejected by a Apple Script that ejects disks

I'm a bit confused because the name Time Machine Backups is predefined in the framework.

The check

Applescript:

name of disks whose name is not "Time Machine Backups"

must exclude the volume reliably.


regards

Stefan

Offline

 

#7 2019-01-27 02:08:37 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 220

Re: Preventing TM disk being ejected by a Apple Script that ejects disks

Morning Stefan,

Could it have to do with the EFI Boot also being loaded?  just a wild guess on my site.

I also tried:

Applescript:

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

But no succes.

Offline

 

#8 2019-01-27 02:33:50 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11550
Website

Re: Preventing TM disk being ejected by a Apple Script that ejects disks

I don't think so. Does the EFI Boot volume appear in the disk list of System Events?


regards

Stefan

Offline

 

#9 2019-01-27 02:47:06 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3325

Re: Preventing TM disk being ejected by a Apple Script that ejects disks

It may help Stefan to post what is returned by :

Applescript:

tell application "System Events"
   set networkVolumes to name of disks whose server is not missing value
end tell

Applescript:

tell application "Finder"
   set volNames to name of the disks
end tell

This way he would know the real names available and see if there is a difference between what is returned by Finder and System Events.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) dimanche 27 janvier 2019 09:46:42

Offline

 

#10 2019-01-27 05:49:48 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 220

Re: Preventing TM disk being ejected by a Apple Script that ejects disks

StefanK wrote:

I don't think so. Does the EFI Boot volume appear in the disk list of System Events?



as posted above it shows in Terminal.

Offline

 

#11 2019-01-27 05:55:43 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 220

Re: Preventing TM disk being ejected by a Apple Script that ejects disks

Yvan Koenig wrote:

It may help Stefan to post what is returned by :

Applescript:

tell application "System Events"
   set networkVolumes to name of disks whose server is not missing value
end tell



Returns: {}

Applescript:

tell application "Finder"
   set volNames to name of the disks
end tell



Returns: {".truecrypt_aux_mnt1", "4916E083-E6669B1-4569871-B13C-820E20CE96DF", "Data", "DiskImage", "MobileBackups", "OS10.12", "OS10.11", "home", "net"}

Offline

 

#12 2019-01-27 06:49:20 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11550
Website

Re: Preventing TM disk being ejected by a Apple Script that ejects disks

ChangeAgent wrote:


as posted above it shows in Terminal.



The Terminal output is irrelevant If you are getting the disks with Finder or System Events.


regards

Stefan

Offline

 

#13 2019-02-03 01:50:25 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 220

Re: Preventing TM disk being ejected by a Apple Script that ejects disks

Anybody has an idea as to how to solve this?

Offline

 

#14 2019-02-07 02:16:06 am

Joy
Member
From:: South Tirol
Registered: 2008-07-04
Posts: 603
Website

Re: Preventing TM disk being ejected by a Apple Script that ejects disks

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

Offline

 

#15 2019-02-07 02:51:48 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 220

Re: Preventing TM disk being ejected by a Apple Script that ejects disks

I tried all you suggested and it is still ejecting the TM disk.

FYI I only posted the Terminal info as information in the hope it help to solve the problem.

So why does it keep ejecting the TM disk?  Is it because it is on a server in the network?

Offline

 

#16 2019-02-07 04:41:02 am

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4808

Re: Preventing TM disk being ejected by a Apple Script that ejects disks

ChangeAgent wrote:
Yvan Koenig wrote:

It may help Stefan to post what is returned by :

Applescript:

tell application "System Events"
   set networkVolumes to name of disks whose server is not missing value
end tell



Returns: {}


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:

Applescript:

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.

Last edited by Nigel Garvey (2019-02-07 05:04:23 am)


NG

Offline

 

#17 2019-02-07 09:03:29 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 220

Re: Preventing TM disk being ejected by a Apple Script that ejects disks

Thanks Nigel will give it a goo, helpful.

Offline

 

#18 2019-02-08 11:17:07 am

Joy
Member
From:: South Tirol
Registered: 2008-07-04
Posts: 603
Website

Re: Preventing TM disk being ejected by a Apple Script that ejects disks

ChangeAgent wrote:

Thanks Nigel will give it a goo, helpful.


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.

Offline

 

#19 2019-02-08 11:34:26 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 220

Re: Preventing TM disk being ejected by a Apple Script that ejects disks

Joy wrote:

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.



Hi Joy, not sure how to interpet your comments.  would you like me to say thank you to all?  Hereby done.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)