Skip to content

Instantly share code, notes, and snippets.

@atr000
Created August 20, 2010 14:57
Show Gist options
  • Save atr000/540489 to your computer and use it in GitHub Desktop.
Save atr000/540489 to your computer and use it in GitHub Desktop.
on open names
set volumeName to names as text
set macAddress to (do shell script "ifconfig en0 | grep ether | tr -d '\\011' | sed s/ether// | sed 's/ //g' | sed s/://g")
set hostName to (do shell script "hostname -fs")
tell application "Finder"
set theSize to round (((capacity of startup disk) / 1024 / 1024) / 1024)
end tell
do shell script "defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1" with administrator privileges
do shell script "sudo hdiutil create -size " & theSize & " -type SPARSEBUNDLE -nospotlight -volname \"Backup of " & hostName & "\" -fs \"Journaled HFS+\" ~/" & hostName & "_" & macAddress & ".sparsebundle" with administrator privileges
do shell script "mv ~/" & hostName & "_" & macAddress & ".sparsebundle /Volumes/" & volumeName & "/" with administrator privileges
tell application "Finder" to eject volumeName
tell application "System Preferences"
activate
end tell
tell application "System Events"
tell application process "System Preferences"
set frontmost to true
click menu item "Time Machine" of menu "View" of menu bar 1
end tell
end tell
end open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment