Tuesday, December 20, 2011

Apple Time Machine and error 45 when using it on a network drive

I just started using Time Machine (Yeah, I know, i'm late to the party) on some Macs I have and to my surprise things did not work from the get go, very un-Apple-like. This occurred on v10.6.8 and v10.5.x.

Anyway, to make it short, I've written a script that fixes this.

Some of the information I pieced together came from this guy's article (http://www.levelofindirection.com/journal/2009/10/10/using-a-networked-drive-for-time-machine-backups-on-a-mac.html).

So, if you get the following error, have at it:

Time Machine could not complete the backup.
The backup disk image "/Volumes/*/*.sparsebundle" could not be created (error 45).

----- Script Starts -----
# Luis Yax - info@yaxmail.com
# This script fixes the below error when setting up TimeMachine on Mac OS X v10.6.8, error 45

echo -e "\nCurrent Volumes mounted: "
ls -1 /Volumes/ | nl; echo " "
echo "Enter your TimeMachine Volume name (if not sure, just press enter): "
read VolumeNameEntered
ComputerMACAddress=`ifconfig | grep -A 1 'en0' | grep "ether" | awk '{print $2}' | sed 's/://g'`
if [ -z "$VolumeNameEntered" ];
echo "VolumeName is empty"
echo "sparsebundle being created, hold on tight ..."
hdiutil create -size 320g -type SPARSEBUNDLE -nospotlight -volname "Backup of $ComputerName" -fs "Case-sensitive Journaled HFS+" -verbose ~/Desktop/$ComputerName"_"$ComputerMACAddress.sparsebundle > /tmp/MyTimeMachineScriptSetup.log 2>&1
IfSuccess=`grep "created: " /tmp/MyTimeMachineScriptSetup.log | awk '{print $5}'`
IfSuccessAnswer=`echo ${IfSuccess//[[:space:]]}`
if [[ "IfSuccessAnswer" -eq "0" ]] && [[ ! -z "$VolumeNameEntered" ]];
echo "Now moving sparsebundle to TimeMachine Volume ..."
echo "Job completed successfully."
echo "The following sparsebundle will have to be moved manually to your TimeMachine volume:"
echo "~/Desktop/"$ComputerName"_"$ComputerMACAddress".sparsebundle"
rm /tmp/MyTimeMachineScriptSetup.log

----- Script Ends -----

No comments: