Dear mates.
I created a backup script that should rsync all local user home folder with exceptions (exception file in /etc/rsync) to the smb network share of this user (subfolder: Backup).
However, I get this error message in the log:
Script result: 0:54: execution error: An error of type -5014 has occurred. (-5014)
/Library/Application Support/JAMF/tmp/backup_smbhome.sh: line 43: /usr/local/bin/rsync: Permission denied
Unmount failed for /Volumes/firstname.lastname
This rsync version is the newer version (3.1.3) than the built-in one and has been successfully installed before to /usr/local/bin .
And here is the script itself:
*#!/bin/bash
create Backup log folder if not existent
if [[ ! -e "/var/log/rsync" ]]; then
/bin/mkdir -p "/var/log/rsync"
# /usr/sbin/chown user:group"/var/log/backup" && /bin/chmod 775 "/var/log/backup"
fi
generate timestamp for log file and deletion folder (if applicable)
d=$(date +%Y-%m-%d_%H-%M-%S)
define log location and name
touch /var/log/rsync/$d.log
LOG="/var/log/rsync/$d.log"
get current User
currentUser=$(stat -f %Su /dev/console)
echo "Current User is $currentUser" >> $LOG
if [[ ! -e "/Volumes/currentUser" ]]
then
## determine path to network share
homeLoc=$( dscl . -read /Users/$currentUser SMBHome | cut -c 10- | sed 's../.g' )
## mount the share
/usr/bin/osascript -e "mount volume "smb:$homeLoc""
echo "$currentUser 's home share has been successfully mounted." >> $LOG
else
echo "$currentUser 's home share is already mounted." >> $LOG
fi
create Backup folder if not existent
if [[ ! -e "/Volumes/$currentUser/Backup" ]]; then
/bin/echo "Backup folder not found." >> $LOG
/bin/echo "Creating Backup folder." >> $LOG
/bin/mkdir -p "/Volumes/$currentUser/Backup"
# /usr/sbin/chown user:group"/Volumes/$currentUser/Backup" && /bin/chmod 775 "/Volumes/$currentUser/Backup"
/bin/echo "The Backup folder has been created." >> $LOG
fi
sleep 2
actual rsync command (archive, verbose, logging)
/usr/local/bin/rsync -av --exclude-from '/etc/rsync/exclusions.txt' --delete-after /Users/$currentUser/ /Volumes/$currentUser/Backup --log-file=$LOG
unmount the share
diskutil umount force /Volumes/$currentUser
/bin/echo "$currentUser's home share has been successfully unmounted." >> $LOG
exit*
As it might be a permission thing, here is the payload of the rsync 3.1.3 package I created within composer:
Does anyone has an idea what might be the issue and how to resolve this?
I try hard to get better in scripting, but I am still some kind of beginner...
Thank you and best regards
Christian