Enable or disable automatic backup of devices in iTunes

When you sync with your iPhone, iPod Touch or other device, iTunes will automatically back the device up. This can often more than double the time a sync takes. This script will disable this. However, this completely disables backing up at all, so you have to enable it again to take a backup ” this script does that too.

Feedback is more than welcome.


set previousDisableBackupValue to do shell script "defaults read com.apple.iTunes DeviceBackupsDisabled"

set cancelBtn to "Cancel"
set enableBackupsBtn to "Enable Backups"
set disableBackupsBtn to "Disable Backups"
set buttonArray to {cancelBtn, enableBackupsBtn, disableBackupsBtn}
set dialogText to "What do you want do set the device backup option to? This will shut down iTunes."

display dialog dialogText buttons buttonArray default button (3 - previousDisableBackupValue) -- default button is the opposite of current setting. Hax.

set choice to button returned of result

set disableBackupValue to (choice is equal to disableBackupsBtn)

if application "iTunes" is running then quit application "iTunes"

do shell script "defaults write com.apple.iTunes DeviceBackupsDisabled -bool " & disableBackupValue

-- quit verb doesn't wait till it's closed; wait for it
repeat while application "iTunes" is running
	delay 0.5
end repeat

launch application "iTunes"