In close collaboration with Seoul National University's Structural Complexity Laboratory

 

Running Multiple Time Machine Disks Automatically in Snow Leopard

What I use:

In /Library/LaunchDaemons/com.bobmckay.timemachine.choose.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.bobmckay.timemachine.choose</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/timemachine.sh</string>
    </array>
    <key>RunAtLoad</key>
    <false/>
    <key>StartOnMount</key>
    <true/>
</dict>
</plist>

In /usr/local/bin/timemachine.sh

#!/bin/bash
# Set up a currently connected disk as Time Machine backup
# Before running, need to
# Get disk names (ls /Volues)
# Get disk UUIDs (diskutil info "$DISKNM" | grep UUID)
# Get disk time machine aliases (enable disk in time machine, then
# check /Library/Preferences/com.apple.TimeMachine BackupAlias) 
# e.g. by 'defaults read' command

echo `date` "Called Time Machine" 
# These need to be previously got from the disks:
BKPALIAS1='<00000000 01860002 0001154d 61634169 72205469 6d65204d 61636869 6e652031 00000000 0000c90e 0e9e482b 00000000 0001154d 61634169 72205469 6d65204d 61636869 6e652031 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0002c90e 0e9e0000 00000000 0000ffff ffff0000 09000000 00000000 00000000 00000000 00154d61 63416972 2054696d 65204d61 6368696e 65203100 00100008 0000c90d 900e0000 00110008 0000c90d 900e0000 00010000 0002002b 4d616341 69722054 696d6520 4d616368 696e6520 313a4d61 63416972 2054696d 65204d61 6368696e 65203100 000e002c 0015004d 00610063 00410069 00720020 00540069 006d0065 0020004d 00610063 00680069 006e0065 00200031 000f002c 0015004d 00610063 00410069 00720020 00540069 006d0065 0020004d 00610063 00680069 006e0065 00200031 00120000 0013001e 2f566f6c 756d6573 2f4d6163 41697220 54696d65 204d6163 68696e65 2031ffff 0000>'
BKPALIAS2='<00000000 01860002 0001154d 61634169 72205469 6d65204d 61636869 6e652032 00000000 0000c910 9abb482b 00000000 0001154d 61634169 72205469 6d65204d 61636869 6e652032 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0002c910 9abb0000 00000000 0000ffff ffff0000 09000000 00000000 00000000 00000000 00154d61 63416972 2054696d 65204d61 6368696e 65203200 00100008 0000c910 1c2b0000 00110008 0000c910 1c2b0000 00010000 0002002b 4d616341 69722054 696d6520 4d616368 696e6520 323a4d61 63416972 2054696d 65204d61 6368696e 65203200 000e002c 0015004d 00610063 00410069 00720020 00540069 006d0065 0020004d 00610063 00680069 006e0065 00200032 000f002c 0015004d 00610063 00410069 00720020 00540069 006d0065 0020004d 00610063 00680069 006e0065 00200032 00120000 0013001e 2f566f6c 756d6573 2f4d6163 41697220 54696d65 204d6163 68696e65 2032ffff 0000>'
#BKPALIAS3='<00000000 014e0002 00010e54 696d6520 4d616368 696e6520 33000000 00000000 00000000 0000cb37 3a1d482b 00000000 00010e54 696d6520 4d616368 696e6520 33000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0002cb37 3a1d0000 00000000 0000ffff ffff0000 09000000 00000000 00000000 00000000 000e5469 6d65204d 61636869 6e652033 00100008 0000cb36 ad7d0000 00110008 0000cb36 ad7d0000 00010000 0002001d 54696d65 204d6163 68696e65 20333a54 696d6520 4d616368 696e6520 3300000e 001e000e 00540069 006d0065 0020004d 00610063 00680069 006e0065 00200033 000f001e 000e0054 0069006d 00650020 004d0061 00630068 0069006e 00650020 00330012 00000013 00172f56 6f6c756d 65732f54 696d6520 4d616368 696e6520 3300ffff 0000>'
BKPALIAS3='<00000000 01860002 0001154d 61634169 72205469 6d65204d 61636869 6e652033 00000000 0000cb63 2ddd482b 00000000 0001154d 61634169 72205469 6d65204d 61636869 6e652033 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0002cb63 2ddd0000 00000000 0000ffff ffff0000 09000000 00000000 00000000 00000000 00154d61 63416972 2054696d 65204d61 6368696e 65203300 00100008 0000cb62 af4d0000 00110008 0000cb62 af4d0000 00010000 0002002b 4d616341 69722054 696d6520 4d616368 696e6520 333a4d61 63416972 2054696d 65204d61 6368696e 65203300 000e002c 0015004d 00610063 00410069 00720020 00540069 006d0065 0020004d 00610063 00680069 006e0065 00200033 000f002c 0015004d 00610063 00410069 00720020 00540069 006d0065 0020004d 00610063 00680069 006e0065 00200033 00120000 0013001e 2f566f6c 756d6573 2f4d6163 41697220 54696d65 204d6163 68696e65 2033ffff 0000>'
DISKNM=`ls /Volumes | grep "Time.Machine"`
if [[ "$DISKNM" =~ 1$ ]] ; then
#if [[ $DISKNM =~ '*1' ]] ; then
  BKPALIAS=$BKPALIAS1
  echo "disk1"
elif [[ "$DISKNM" =~ 2$ ]] ; then
  BKPALIAS=$BKPALIAS2
  echo "disk2"
elif [[ "$DISKNM" =~ 3$ ]] ; then
  BKPALIAS=$BKPALIAS3
  echo "disk3"
fi
echo "Backup Alias is :" $BKPALIAS
if [ -n "$DISKNM" ] ; then 
  mountedDisk=`diskutil info "$DISKNM" | awk '/UUID/ {print $3}'`;
  echo $mountedDisk;
  if test $mountedDisk; then 
    echo "Mounted Disk UUID: $mountedDisk";
    configuredDisk=`defaults read /Library/Preferences/com.apple.TimeMachine DestinationUUID`;
    echo "Configured Disk UUID: $configuredDisk";
    if test $mountedDisk = $configuredDisk; then
        echo "Configuration is correct."
    else
        echo "Configuration requires update. Updating..."
        defaults write /Library/Preferences/com.apple.TimeMachine DestinationUUID $mountedDisk
        defaults write /Library/Preferences/com.apple.TimeMachine BackupAlias "$BKPALIAS"
        echo "done."
    fi
  else
    echo "SCRIPT BUG"
  fi
else 
    echo "No Backup HD found."
fi