Posted on 02-26-2019 06:56 AM
Hey guys i've been back and fourth doing this project. I am getting an error with after running this script. Everything runs fine and then the sparsebundle fails to begin backing up. The error is unable to get status of backup disk. Here are the commands that I put together.
LOGGED_IN_USER=$(stat -f%Su /dev/console)
if [[ ! -e /Volumes/QTimeMachineBackups ]]; then
mkdir -p /Volumes/QTimeMachineBackups
fi
if [[ ! -e /Volumes/QTimeMachineBackups/$LOGGED_IN_USER.sparsebundle ]]; then
mount -t afp 'afp://Time_Machine_User:Password/QTimeMachineBackups' /Volumes/QTimeMachineBackups
fi
#Creates encrypted sparsebundle on Synology that gives itself a name based on account username
if [[ ! -e /Volumes/QTimeMachineBackups/$LOGGED_IN_USER.sparsebundle ]]; then
/usr/bin/printf 'password' | /usr/bin/hdiutil create -size 200g -volname "$LOGGED_IN_USER" -encryption AES-256 -type SPARSEBUNDLE -fs "HFS+J" -stdinpass "/Volumes/QTimeMachineBackups/$LOGGED_IN_USER"
fi
#Mounts the NAS sparsebundle based on specific user
if [[ ! -e /Volumes/QTimeMachineBackups/$LOGGED_IN_USER.sparsebundle ]]; then
/usr/bin/printf 'password' | /usr/bin/hdiutil attach -stdinpass /Volumes/QTimeMachineBackups/$LOGGED_IN_USER.sparsebundle
fi
#Sets specific users sparse bundle as a time machine destination
umount -f /Volumes/QTimeMachineBackups
tmutil setdestination -a "afp://Time_Machine_User:Password/QTimeMachineBackups/$LOGGED_IN_USER.sparsebundle"
#tmutil setdestination /Volumes/QTimeMachineBackups/$LOGGED_IN_USER.sparsebundle
#Makes Backup Speed Increase
sysctl debug.lowpri_throttle_enabled=0
#Enables automatic backups
tmutil enable
#Starts backups
tmutil startbackup
)
Posted on 02-26-2019 08:05 AM
@kadams I'm sure there's a solution here to get this working. To start with, so it's easier to digest, can you edit your post and surround your script with the script tags? Either add a ``` to the top and bottom of the script, or highlight the whole script and click the >_
button in the post editing toolbar.
Posted on 02-26-2019 08:16 AM
Off the top of my head, one possible problem I see is with this line
tmutil setdestination -a "afp://Time_Machine_User:Password/QTimeMachineBackups/$LOGGED_IN_USER.sparsebundle"
I may be wrong, but I don't believe you should include the .sparsebundle
extension in the path name. I think tmutil needs a standard mount path for this command, which would not have a file extension on it. When any DMG is mounted, sparsebundle or not, it just has a volume name, no extension included.
One way to test this would be to see if the above path of QTimeMachineBackups/$LOGGED_IN_USER.sparsebundle
(replacing $LOGGED_IN_USER with the actual name) resolves in the Terminal. It you can't navigate to that path in Terminal when the sparse bundle is mounted, then that might be the problem. If so, try dropping the .sparsebundle extension and use the path without it to see if there's an improvement.
Posted on 02-27-2019 09:31 AM
@mm2270 , I changed it and it still doesn't work.
Posted on 02-27-2019 05:39 PM
Finally got it to work!
Posted on 02-28-2019 06:11 AM
@mm2270 The computer rebooted and gave me the prohibitory symbol after restoring from time machine.