With the purchase of the Apple Thunderbolt Display my Air now has a jumbo-frame enabled ethernet port at its disposal. My current backup strategy is to utilize an encrypted external USB laptop drive while on the road and to just rsync the latest backup when I get home. This has been working great for a year straight (saved my greasy bacon when the airlines forgot my bag) but I figured it was time to reevaluate with my fancy monitor in the mix.
- Apple Thunderbolt Display
- MacBook Air 11″
- OS X 10.7 Lion which added the tmutil command
- Iomega eGo USB Drive
- Debian 6.0 Server with oodles of encrypted disk space
- Gigabit network
- ControlPlane for geolocation detection
Secret Magic Scripts:
First we need to create a HOME script. This will be called when the MacBook Air detects that it is on a super-fast connection instead of that yucky Wifi.
sudo vi /opt/local/bin/switchtimemachinehome.sh
#!/bin/bash #This will change your Time Machine setting the backup to your home server sleep 5 tmutil setdestination afp://username:firstname.lastname@example.org/TimeMachineNAS/ sleep 5 tmutil startbackup
Obviously you will want to modify the username:password and destination. Something that will trip you up (hopefully) is your complex password does not work in the URL. If this is the case then please use the below AppleScript to modify it for you. Standard POSIX/UNIXy type things do not work.
Open AppleScript Editor and put in the following and run
set theText to "I want to pass this text, via GET, to a url!" set theText to text returned of (display dialog "encode what" default answer theText) set theTextEnc to urlencode(theText) of me display dialog theTextEnc default answer theTextEnc on urlencode(theText) set theTextEnc to "" repeat with eachChar in characters of theText set useChar to eachChar set eachCharNum to ASCII number of eachChar if eachCharNum = 32 then set useChar to "+" else if (eachCharNum ≠ 42) and (eachCharNum ≠ 95) and (eachCharNum < 45 or eachCharNum > 46) and (eachCharNum < 48 or eachCharNum > 57) and (eachCharNum < 65 or eachCharNum > 90) and (eachCharNum < 97 or eachCharNum > 122) then set firstDig to round (eachCharNum / 16) rounding down set secondDig to eachCharNum mod 16
if firstDig > 9 then set aNum to firstDig + 55 set firstDig to ASCII character aNum end if if secondDig > 9 then set aNum to secondDig + 55 set secondDig to ASCII character aNum end if
set numHex to ("%" & (firstDig as string) & (secondDig as string)) as string set useChar to numHex end if set theTextEnc to theTextEnc & useChar as string end repeat return theTextEnc end urlencode
After that we need to give ControlPlane something to call when we are on the road and have nothing but that simple USB drive we lug around.
sudo vi /opt/local/bin/switchtimemachinemobile.sh
#!/bin/bash #This will change your Time Machine setting the backup to your home server sleep 5 tmutil setdestination /Volumes/RubbageHolder/ sleep 5 tmutil startbackup
Lets now make both files executable or the scripts will fail
sudo chmod +x /opt/local/bin/switchtimemachinehome.sh
sudo chmod +x /opt/local/bin/switchtimemachinemobile.sh
Letting the Penguins talk to the Fruit:
In order for our Debian server to be useful we need to give it a secret decoder ring. This means installing some software and announcing itself a certain way for the Mac machines to recognize it as a Mac Server. You can also do this with a standard Mac server, but I prefer my servers to be Linux/BSD based. NOTE: If you are securing your backups using encrypted USB drives, but fail to encrypt your home NAS – SHAME ON YOU! So lets get started by issuing a SSH to our home server.
- sudo apt-get install netatalk avahi-daemon
- sudo vi /etc/netatalk/AppleVolumes.default
- Add the line: /share/Backup “TimeMachineNAS” options:tm to the end of the file
<?xml version="1.0" standalone='no'?><!--*-nxml-*--> <!DOCTYPE service-group SYSTEM "avahi-service.dtd"> <service-group> <name replace-wildcards="yes">%h</name> <service> <type>_afpovertcp._tcp</type> <port>548</port> </service> <service> <type>_device-info._tcp</type> <port>0</port> <txt-record>model=Xserve</txt-record> </service> <service> <type>_adisk._tcp</type> <port>9</port> <txt-record>sys=waMA=00:00:00:00:00,adVF=0x100</txt-record> <txt-record>dk0=adVF=0x83,adVN=TimeMachineNAS</txt-record> </service> </service-group>
Convince the Mac its right at home:
Location, Location, Location:
5. First rule states the en3 link is active and context is HOME
android apologetic apple catholic christian dating debian encryption geek God google howto iphone life linux love mac military nokia Personal phone poetry politics pope relationship relationships religion religious review running security tech Techie technology theology travel tweets twitter ubuntu UNIX video vintage vmware work writing
- Nick Schmidt lives passionately in the digital world advising and advancing technology everywhere he goes. He has served in the US Air Force, been a self-employed consultant, a senior manager and chief engineer at Boeing, and now co-founding and running Spec Ops Technology. Decorated in his military and professional career you can find his work in the nations networks and across the web.