Cannot mount snapshot when executed with launchd

I have a script which uses duplicacy to back up some data. It runs fine when I run it in the Mac Terminal under Mojave with sudo.

When I try to execute the same script with a launchd agent and root as the executing user I get the following error:

Error while mounting snapshot: %!(EXTRA *exec.ExitError=exit status 73)

What could be the cause of this?

Please make sure that the script is run as root. This error may mean it doesn’t have the administrator privileges to mount the snapshot.

The error message format is wrong – this has been fixed in the latest version.

Strange, the launchd job is run by root. But I will recheck. Thanks for the explanation.

Same problem again on Mojave 10.14.6. Snapshot creation when triggered by launchd fails with error 73 given by duplicacy. Also when started as root. What can I provide to help?

Is SIP enabled? If so, Duplicacy does not have privileges to see sensitive user data. You can only grant full disk access privilege to application bundles, not naked executables. It works in the terminal because the terminal is an app bundle to which you have granted access.

If you have to run Duplicacy as root — disable SIP.

I was able solve this by running the script that calls duplicacy with bash in the launchd command line: /bin/bash /path/to/script.sh and giving bash full disc access in the security preference pane.

This is a bad idea. Might as well disable sip in the first place.

You can create wrapper for Duplicacy in Automator and rice wrapper the full disk access instead.