Showing posts with label "Network error". Show all posts
Showing posts with label "Network error". Show all posts

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 -----
#/bin/sh
# Luis Yax - info@yaxmail.com
# This script fixes the below error when setting up TimeMachine on Mac OS X v10.6.8, error 45

clear;
echo -e "\nCurrent Volumes mounted: "
ls -1 /Volumes/ | nl; echo " "
echo "Enter your TimeMachine Volume name (if not sure, just press enter): "
read VolumeNameEntered
ComputerName=`hostname`
ComputerMACAddress=`ifconfig | grep -A 1 'en0' | grep "ether" | awk '{print $2}' | sed 's/://g'`
if [ -z "$VolumeNameEntered" ];
then
echo "VolumeName is empty"
else
MyTimeMachine=$VolumeNameEntered
fi
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:]]}`
clear
if [[ "IfSuccessAnswer" -eq "0" ]] && [[ ! -z "$VolumeNameEntered" ]];
then
echo "Now moving sparsebundle to TimeMachine Volume ..."
echo "Job completed successfully."
else
echo "The following sparsebundle will have to be moved manually to your TimeMachine volume:"
echo "~/Desktop/"$ComputerName"_"$ComputerMACAddress".sparsebundle"
fi
rm /tmp/MyTimeMachineScriptSetup.log

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