1

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?

1
  • temporary work round: use automator's record/watch me do; shortcoming is this approach will move the mouse pointer around – egwene sedai Sep 20 '19 at 19:38
3

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.

3
  • Thanks! It's a very nice alternative but may need usb connection, whereas the backup function in Finder (used to be itunes) can work over wifi. – egwene sedai Sep 21 '19 at 13:39
  • If the device is managed, you should be able to backup over wi-fi, I think – Harcker Sep 21 '19 at 13:41
  • thanks! I'll try that out – egwene sedai Sep 21 '19 at 14:07
3

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
1
  • This works like a charm. Over wifi too. cfgutil doesn't. – Michael Rourke Jun 14 '20 at 7:15
0

If you are looking to keep your automatic iCloud backups going and have the ability to schedule this script for auto backups, I added in the selection of the radio button for "Back up all of the data on your iPhone to this Mac"

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 "enter name of your phone here" then
        set ux to iter
        exit repeat
    end if
end repeat
tell ux
    perform action "AXOpen"
end tell

repeat until exists (radio button "Back up all of the data on your iPhone to this Mac" 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 (radio button "Back up all of the data on your iPhone to this Mac" 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

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

0

So, I've used the applescripts posted here and they work perfect.

Now, I want to schedule them periodically (daily) at some hour in the night.

I've tried using launchd and periodic services, but when they run the script in the night when laptop is sleeping, I get: "execution error: System Events got an error: Application isn’t running. (-600)" Not sure what is not running - System Events or the Finder?? Any idea how to make the script work when lid is closed?

New contributor
Guy Erlich is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .