How can I set Time machine interval to several minutes in Mojave?

Solution 1:

NVM I figured it out.

This is a great timing to finish the answer, right? ...No? Okay I'll show you what was the problem then...

What is required to do that in Mojave is:

  1. disable csrutil.
  2. sudo vi /System/Library/LaunchDaemons/com.apple.backupd-helper.plist, and then edit Interval, Delay, GracePeriod. I just set them to 1/4 of original value.
  3. Reboot. You were going to re-enable csrutil anyway, right?

After that, time machine prefpane will still say it's going to backup 1hr after last backup, but automatic backup happens 15 mins later in my case.

Solution 2:

Try the free utility TimeMachineEditor. It allows you to set just about any kind of schedule you want. Way easier and way more versatile than manually editing files.

Solution 3:

If you're sure this is something that you want to do, I think the best way to try it is to use the tmutil (Time Machine utility).

Quoting man tmutil

startbackup

Begin a backup if one is not already running.

Options:
--auto Run the backup in a mode similar to system-scheduled backups.
--block Wait (block) until the backup is finished before exiting.
--rotation Allow automatic destination rotation during the backup.
--destination Perform the backup to the destination corresponding to the specified ID.

The --auto option provides a supported mechanism with which to trigger "automatic-like" backups, similar to automatic backups that are scheduled by the system. While this is not identical to true system-scheduled backups, it provides custom schedulers the ability to achieve some (but not all) behavior normally exhibited when operating in automatic mode.

Combine that with launchd and you can have tmutil run every 15 minutes, take this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.tjluoma.time-machine-intervals</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/bin/tmutil</string>
        <string>startbackup</string>
        <string>--auto</string>
        <string>--rotation</string>
    </array>
    <key>RunAtLoad</key>
    <false/>
    <key>StandardErrorPath</key>
    <string>/tmp/com.tjluoma.time-machine-intervals.stderr.log</string>
    <key>StandardOutPath</key>
    <string>/tmp/com.tjluoma.time-machine-intervals.stdout.log</string>
    <key>StartInterval</key>
    <integer>900</integer>
</dict>
</plist>

and save it as ~/Library/LaunchAgents/com.tjluoma.time-machine-intervals.plist and then load it into launchd with this command in Terminal:

launchctl load ~/Library/LaunchAgents/com.tjluoma.time-machine-intervals.plist

Here's how it looks in LaunchControl which is my favorite app for working with launchd plists:

LaunchControl screenshot