Wednesday, May 18, 2011

Time machine on a network drive

A very good explanation of how to use a network drive for time machine. However, there is no need to reboot your OS X once you change the setting. I also make a shell script to create a time machine compatible network drive using all the above steps automatically. Enjoy!



#!/bin/sh
# Create a time machine compatible network drive 
# (c) codebytez.blogspot.com
NETLOC=$1
if [ -z "$1" ]
then
        echo Usage: $0 /Volumes/network_volume \[size\]
        exit 1
fi

if [ -z "$2" ]
then
        SIZE=100g
else
        SIZE=$2
fi

defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1
MAC=`ifconfig en0 | grep ether | perl -lne 'print @f if (@f = /[0-9a-f]{2}/g)'`
HOST=`echo $HOSTNAME | perl -F'\.' -lane 'print $F[0]'`
VOL=${HOST}_${MAC}.sparsebundle
hdiutil create -size $SIZE -fs HFS+J -volname "Time Machine" $VOL
rsync -aE $VOL $NETLOC
rm -rf $VOL
echo Created $NETLOC/$VOL
echo Select as backup disk in Time Machine Preferences

No comments: