Catalina: backup iOS devices programatically
Before Catalina, I used to be able to use a simple AppleScript to open iTunes and select the menubar to back up connected iPhone/iPad; In Catalina, this function is moved to Finder and so far I haven't been able to find out how to click in the Finder's sidebar > location > iPhone. Has anyone had any luck with that?
Solution 1:
Apple Configurator 21 has a command line utility cfgutil
, which can be installed from the menubar in Apple Configurator
.
With cfgutil
installed, you can run the command: cfgutil backup
Apple Configurator 2 includes an Automator action too, which does the same as the above command.
1Currently requires macOS version 10.14.6 or later.
Solution 2:
Also, for when one does not wish to put the ios device in supervised mode, this appplescript works for me (set [your_ios_device_name] accordingly)
tell application "System Events" to tell application process "Finder"
set frontmost to true
tell front menu bar to tell menu "File" to tell menu item "New Tab"
perform action "AXPress"
end tell
set uis to (first UI element of row of (outline 1 of scroll area 1 of splitter group 1 of front window) as list)
repeat with iter in uis
if name of iter is "[your_ios_device_name]" then
set ux to iter
exit repeat
end if
end repeat
tell ux
perform action "AXOpen"
end tell
repeat until exists (button "Back Up Now" of scroll area 1 of group 1 of group 1 of splitter group 1 of splitter group 1 of front window)
delay 0.3
end repeat
set btn to (button "Back Up Now" of scroll area 1 of group 1 of group 1 of splitter group 1 of splitter group 1 of front window)
repeat until enabled of btn
delay 0.3
end repeat
click btn
end tell