Start or Stop TM Backup

Hi All,

Here’s a little script to be used as a script or an Automator service to give you a way to have a hotkey for starting or stopping TM backups using the new command line TM interface. Put it in an Automator service and give it a hotkey like control-option-b or something.

Enjoy,

Tim

on run
	set TMIcon to a reference to file (((path to applications folder) as text) & "Time Machine.app:Contents:Resources:backup.icns")
	set TimeStatus to do shell script "tmutil status"
	if TimeStatus does not contain "Stopping = 1;" then
		if TimeStatus contains "Running = 0;" then
			do shell script "tmutil startbackup −a"
			display notification " " with title "Time Machine" subtitle "Manual Backup Initiated"
		else if TimeStatus contains "Running = 1;" then
			set StopBackup to button returned of (display dialog "Time Machine is already performing a backup." & return & "Stop backup?" buttons {"Quit", "Stop Backup"} default button "Stop Backup" cancel button "Quit" with icon TMIcon)
			if StopBackup is "Quit" then return 0
			try
				do shell script "tmutil stopbackup"
			end try
			display notification " " with title "Time Machine" subtitle "Backup Cancelled"
		end if
	else
		return 0
	end if
	--do shell script "/System/Library/CoreServices/backupd.bundle/Contents/Resources/backupd-helper -auto >/dev/null 2>&1 &"
end run