0

This problem is similar to questions at the following:

I had similar problems in Monterey and previous OS versions, but they were resolvable. The same solutions do not work in Ventura.

Here is the problem:

  1. I have a batch script that executes an rsync command. The command is as follows: sudo rsync -av --delete --exclude=/Volumes/Backup1/.DocumentRevisions-V100 --exclude=/Volumes/Backup1/.TemporaryItems --exclude=/Volumes/Backup1/.Trashes /Volumes/Backup1/ /Volumes/Backup2/

  2. This command works fine from the command line.

  3. There were various permission issues that required the addition of sudo and the exclude parameters. Without those, the command line version gives errors on Ventura that were not given on Monterey.

  4. The command also works fine when executed from within a script. Script shown below.

  5. Running the script as a test (using Lingon X) from launchd gives the following output:

    Start clone /Volumes/Backup1 to /Volumes/Backup2 2023-07-26 11:28:01 sudo rsync -av --delete --exclude=/Volumes/Backup1/.DocumentRevisions-V100 --exclude=/Volumes/Backup1/.TemporaryItems --exclude=/Volumes/Backup1/.Trashes /Volumes/Backup1/ /Volumes/Backup2/ rsync: opendir "/Volumes/Backup1/." failed: Operation not permitted (1) rsync error: some files could not be transferred (code 23) at /AppleInternal/Library/BuildRoots/c2cb9645-dafc-11ed-aa26-6ec1e3b3f7b3/Library/Caches/com.apple.xbs/Sources/rsync/rsync/main.c(996) [sender=2.6.9] End clone /Volumes/Backup1 to /Volumes/Backup2 2023-07-26 11:28:01

Here is the script:

#!/bin/bash

# based on https://gitlab.com/ramawat/randomhacks/blob/master/backup_script.txt

# Halt the script on any errors.
# set -e

# paths
# 1. rsync has trouble when paths have embedded spaces so avoid
# 2. paths must have trailing /, but volume detection must not, so do not include in variables, but add into the command below as needed
SRC_PATH="/Volumes/Backup1"
DEST_PATH="/Volumes/Backup2"
#LOG_PATH="/Volumes/Backup1/RH-backup/dbtemp/backup-clone-$(date "+%Y-%m-%d").log"
#LOG_PATH="/Volumes/Backup1/RH-backup/dbtemp/backup-clone.log"
#LOG_PATH="/var/log/webapps/RH-backup/backup-clone.log"
LOG_PATH="/Users/jas/Websites/RepHunter/log/webapps/RH-backup/backup-clone.log"

# A list of absolute paths to backup. (Examples shown)
# include_paths=(
#   "${HOME}/Movies"
# )

# A list of folder names and files to exclude.
exclude_paths=(
#   ".*"
    "/Volumes/Backup1/.DocumentRevisions-V100"
    "/Volumes/Backup1/.TemporaryItems"
    "/Volumes/Backup1/.Trashes"
)

# Passing list of paths to exclude
for item in "${exclude_paths[@]}"
do
  exclude_flags="${exclude_flags} --exclude=${item}"
done

# Passing list of paths to copy
for item in "${include_paths[@]}"
do
  include_args="${include_args} ${item}"
done

# Finally, rsync with a few flags:
#  -a is archive mode
#  -v is verbose mode
#  --delete removes files from DEST_PATH that do not exist on SRC_PATH

echo ==================== | tee -a  ${LOG_PATH}
echo Start clone ${SRC_PATH} to ${DEST_PATH} | tee -a ${LOG_PATH}
echo $(date "+%Y-%m-%d %I:%M:%S") | tee -a ${LOG_PATH}

# Executing the script only if both SRC_PATH and DEST_PATH are mounted
if mount | grep "on $SRC_PATH" > /dev/null; then
  if mount | grep "on $DEST_PATH" > /dev/null; then
    echo sudo rsync -av --delete  ${exclude_flags} ${SRC_PATH}/ ${DEST_PATH}/ | tee -a ${LOG_PATH}
    sudo rsync -av --delete  ${exclude_flags} ${SRC_PATH}/ ${DEST_PATH}/ >> ${LOG_PATH}
  else
    echo "Dest $DEST_PATH not mounted" | tee -a ${LOG_PATH}
    echo "Backup failed" | tee -a ${LOG_PATH}
  fi
else
  echo "Source $SRC_PATH" not mounted | tee -a ${LOG_PATH}
  echo "Backup failed" | tee -a ${LOG_PATH}
fi
echo End clone ${SRC_PATH} to ${DEST_PATH} $(date "+%Y-%m-%d %I:%M:%S") | tee -a ${LOG_PATH}
echo ==================== | tee -a  ${LOG_PATH}

Here are the steps I have take to try to deal with this, starting from the configuration that worked on Monterey but not on Ventura:

  1. The command that was working on Monterey did not have sudo or the exclude parameters. When that was run on Ventura, got error messages like the following:

rsync: opendir "/Volumes/Backup1/.DocumentRevisions-V100" failed: Permission denied (13)

rsync: opendir "/Volumes/Backup1/.TemporaryItems" failed: Permission denied (13)

rsync: opendir "/Volumes/Backup1/.Trashes" failed: Permission denied (13)

As an aside, I found that rsync had a bug back in 2011 with this issue. I posted to that ticket at --- (to be filled in later).

  1. So I added those files to the exclude list. That seemed to help in reducing initial errors; however, still failed to do the “delete” portion of the rsync command.

  2. Add the sudo to the front of the rsync command, and the "delete" part of rsync now runs.

  3. Add the Add Full Disk Access to both rsync and launchd. No help for running from launchd.

  4. Change perms on the source volume because it was overly restricted for some reason, and that corresponds to the error message "rsync: opendir "/Volumes/Backup1/." failed: Operation not permitted (1)".

None of these help, and the launchd command fails every time, where as both the rsync command itself from the command line and the script containing it from the command both run every time.

As another aspect, I checked that SIP status. It is enabled on both the Ventura and Monterey machines. I am thinking I might temporariy disable it on the Ventura machine to see if that helps. Will report back with that.

0

You must log in to answer this question.

Browse other questions tagged .