Toggle Time Machine Backups On and Off

Does anyone have a macro for Toggling Time Machine backups on and off in macOS Ventura? I had an AppleScript that did this in Monterey, but Apple changed the interface and this no longer works. Instead, you have to switch the backup frequency to Manual.

I have a macro that turns the frequency to “Manual,” but it won't work to turn it back on to “Automatically every hour.” I think I need an If/Then statement to check Time Machine's current backup frequency.

Does anyone know how to do this?

@ccstone - tagging you here in case you know. Thanks.

Here's my current macro:

Display-Macro-Image

According to the tmutil manual, you can enable and disable automatic backups on the command line.

My macro Mirror Mirror has an action that calls tmutil to do a backup on demand (which works in Monterey), if you need an example.

1 Like

That doesn't appear to work in macOS Ventura. There's not an “enable” option for Time Machine.

Echoing @mrpasini, you're better off doing this via an "Execute Shell Script" action.

You'll need to do some setup first -- enabling and disabling Time Machine via tmutil requires sudo so you'll have to allow those commands to be executed without requiring a password. Open Terminal. Type in whoami, hit Return, and copy the text returned -- your short username.

Still in Terminal, type sudo visudo /private/etc/sudoers.d/tmutil and hit Return -- enter your password if asked. Type i to enter interactive mode then ⌘V to paste in your short username, a space, then ALL=NOPASSWD: /usr/bin/tmutil enable, /usr/bin/tmutil disable, !/usr/bin/tmutil enable *, !/usr/bin/tmutil disable *. Press the esc key then type :wq and hit Return to write-and-quit.

You can then use the following in an "Execute Shell Script" action:

#!/bin/bash
if [ $(/usr/bin/defaults read /Library/Preferences/com.apple.TimeMachine.plist AutoBackup) == 1 ]; then
	sudo /usr/bin/tmutil disable;
else
	sudo /usr/bin/tmutil enable;
fi

...to toggle Time Machine. And the macro can be as simple as

Toggle Time Machine.kmmacros (2.0 KB)

Tested on Ventura -- if it isn't working for you, double-check the sudoers file created earlier, and that KM and Terminal have "Full Disk Access".

2 Likes

That worked! Thanks so much.