0

When I run restic from a commandline with sudo it is actually able to backup my Photos library. But this is probably because I have given Terminal full disk access.

I am actually starting restic from a script of my own. But it works fine.

I also have created a launchd schedule. But when it runs from there, I get these permissions errors, like:

scan: open /Users/gerben/Pictures/Photos Library.photoslibrary: operation not permitted

The launchd plist contains:

    <key>ProgramArguments</key>
    <array>
        <string>/opt/local/etc/restic/rna-run-restic.sh</string>

That script, which is multi-system, so can run on macOS and on Linux with docker, starts with

#!/bin/bash
# R&A restic interface script

# Make shure we're running bash >4
if [ -n "$BASH_VERSION" ]; then
    # Extract the major version number (first number) of BASH_VERSION
    major_version="${BASH_VERSION%%.*}"

    # Check if the major version is less than 5
    if [ "$major_version" -lt 5 ]; then
        # Re-execute the script with /opt/local/bin/bash
        exec "/opt/local/bin/bash" "$0" "$@"
    fi
else
    # Re-execute the script with /opt/local/bin/bash
    exec "/opt/local/bin/bash" "$0" "$@"
fi

And at some point on macOS, this launches /opt/local/bin/restic (installed by MacPorts) with the correct arguments, e.g. something like:

/opt/local/bin/restic --verbose -p -passwd.txt -r rest:https://fqdn:port/ backup --host foo --tag pictures --files-from /opt/local/etc/restic/etc/foo-includes-pictures.txt

But while from Terminal, I can run that backup, I cannot from launchd. How do I fix that?

0

1 Answer 1

0

OK, I seem to have found the 'solution': for this to work you must give bash full disk access. Don't like that, but I do not know what a better working solution is.

Update: A better solution is https://github.com/sveinbjornt/Platypus

0

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