1

So, I've got some scripts that use rsync to periodically backup folders on my MBP, but once I moved to catalina they stopped working when invoked by periodic or by launchd.

This is clearly a permissions thing because the scripts work fine when I run them by hand. The problem is, I can't figure out what I need to give permissions to... any ideas?

Here's a sample of the scripts:

#!/bin/bash

DESTDIR="/Volumes/GoPro Video"
DESTINATION=$DESTDIR

# Source is relative to the home directory.
SOURCEDIR=/Users/michaelheinz/Movies
SOURCE="."

OPTIONS='-rltPW --relative'

echo "cd \"$SOURCEDIR\"; rsync $OPTIONS \"$SOURCE\" \"$DESTINATION\""

(cd "$SOURCEDIR"; rsync $OPTIONS "$SOURCE" "$DESTINATION"; if [[ $? -eq 0 ]]; then echo SUCCESS; else echo "FAILURE"; fi) 2>&1 | tee /tmp/$$.log

LOGFILE=$(basename ${0})
mv /tmp/$$.log /var/log/mwh/${LOGFILE}.mwh

A typical error might be:

[Matilda bin]> cat /var/log/mwh/sync_gopro_videos.mwh 
building file list ... 
147 files to consider
./
rsync: failed to set times on "/Volumes/GoPro Video/.": Operation not permitted (1)
rsync: failed to set times on "/Volumes/GoPro Video/.": Operation not permitted (1)

sent 3703 bytes  received 26 bytes  7458.00 bytes/sec
total size is 24761084481  speedup is 6640140.65
rsync error: some files could not be transferred (code 23) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-54/rsync/main.c(996) [sender=2.6.9]
FAILURE
[Matilda bin]> 

dmesg reports lines of messages like this:

System Policy: deny(1) file-read-data /Volumes/APFS-Photos/Libraries/2020.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSLocationCache.sqlite-walSandbox: rsync(36610) 

This is from a job that ran today, I also have had jobs fail outright because the job doesn't have permission to access an external drive. I've tried giving full disk access to periodic, to rsync, and to the scripts themselves. (I've also partially worked around the issue by moving some folders to /Users/Shared/ but that isn't practical for all cases.

I've tried running the script from a launchd plist in /Library/LaunchDaemons with UserName set to root, set to me, running from periodic, adding the rsync binary to Full Disk Access, nothing seems to help.

Any ideas?

  • I would at least start by making sure your variables are all quoted properly DESTINATION="$DESTDIR" and add a PATH= line which matches what you're using in Terminal. – TJ Luoma Mar 07 '20 at 17:03
  • Again, these scripts work correctly both when I run them by hand and in previous versions of macOS. It’s only with the update to Catalina that running them from periodic and launchd has stopped working. – Mike Heinz Mar 07 '20 at 21:16
  • A fair point about the quotes around DESTDIR though. It can’t hurt and is almost certainly safer. – Mike Heinz Mar 07 '20 at 21:23
  • Yeah, this definitely seems like Catalina's permissions / security / Windows Vista-ness biting you, but I'm not sure how to diagnose. Do you have a StandardErrorPath and StandardOutPath set for the launchd jobs? Might tell you a bit more than dmesg? – TJ Luoma Mar 07 '20 at 21:41

0 Answers0