0
<key>ProgramArguments</key>
<array>
  <string>/usr/local/bin/backup.sh</string>
</array>

Running /usr/local/bin/backup.sh requires access to ~/Documents.

My gut feeling is I have to allow an app in "Security & Privacy", but which one and is that secure?

3
  • Sometimes I feel the level of security Apple imposes in macOS is a bit ridiculous! Anyway, launchd is responsible for running of agents and daemons in the various locations they are stored. The user cannot selectively manually add programs to Files and Folders under System Preferences > Security & Privacy > Privacy, the system has to prompt the user for permission. However, the user can add launchd to Full Disk Access. Don't know if this will solve your issue but it's a place to start. It might also be worth seeing the code in the shell script. Nov 6, 2020 at 21:40
  • When using Launch Agents and Launch Daemons, I highly recommend reading the manual pages for launchctl, launchd.plist and launchd. You can read the manual page for command in Terminal by typing command and then right-click on it and select: Open man Page Nov 6, 2020 at 21:42
  • 1
    Thanks for your help @user3439894. I found how to solve the problem. See answer bellow.
    – sunknudsen
    Nov 6, 2020 at 22:23

1 Answer 1

1

The following worked!

I created an app using "Script Editor" that runs /usr/local/bin/borg-backup.sh using zsh.

do shell script "zsh /usr/local/bin/borg-backup.sh"

I then exported the app to /Applications/borg-backup.app clicking "File" then "Export..." choosing "Application" for "File Format".

Finally, I updated ~/Library/LaunchAgents/local.borg-backup.plist.

<key>ProgramArguments</key>
<array>
  <string>open</string>
  <string>/Applications/borg-backup.app</string>
</array>

The first time the launch agent ran, a prompt asked me to grant borg-backup.app access to ~/Documents.

You must log in to answer this question.

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