6

I want to set Time machine interval to 15 minutes, instead of Apple default 1hr.

What I want is:

  1. Time machine Interval of 15 minutes.
  2. Time machine backup should respect battery/power status, meaning backup should not occur while not connected to power.

I tried sudo defaults write /System/Library/LaunchDaemons/com.apple.backupd-auto StartInterval -int 1800 but it doesn't work.

I also tried disabling csrutil and modified /System/Library/LaunchDaemons/com.apple.backupd-helper.plist's Interval, Delay, GracePeriod but it also does not work.

How can I configure that in Mojave? (Currently running 10.14.2)

1
  • csrutil is SIP (System Integrity Protection), and got may want to add that for clarity
    – Sam
    Dec 7 '18 at 21:47
5

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.

1
  • By the way, anybody know what these numbers Interval, Delay, GracePeriod actually are? I set them 1/4 of their original value out of laziness.
    – ik1ne
    Dec 7 '18 at 13:52
3

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.

5
  • Used that before, it works great - not used it on Mojave though... plus 1
    – Solar Mike
    Dec 7 '18 at 21:21
  • That doesn't allow me to set interval to minutes. I know, it's possible to set scheduled backup manually, but I'd rather make a backup hotkey and press that whenever I save a file instead of adding 4*24=96 schedules.
    – ik1ne
    Dec 8 '18 at 2:25
  • 1
    If your real goal is to backup whenever a file changes, then Time Machine is not the right tool. For one thing, it not only backs up the file that you just saved. but also all other files that have changed on your drive. Which can make for long backup times if lots of files have changed (e.g. system files, cache files, etc.). Instead of Time Machine, I would suggest you use something like ChronoSync that can be configured to trigger a backup of a folder whenever a file changes within that folder. That way you are only backing up the files that you have personally changed.
    – user128998
    Dec 9 '18 at 14:43
  • @user128998 Oh... never heard of it, and after reading its description I think it's a perfect solution for me(After editing backupd-helper.plist, I actually was doing tmutil listbackups and tmutil compare A B to exclude all OS files manually). I downloaded the trial version and will give it a try. Thank you!
    – ik1ne
    Dec 10 '18 at 12:59
  • I don’t use that “live sync” feature very often, but when I do, it is invaluable. As I recall it is a scheduling option that you set, and not something that is part of the sync document itself. Let me know if you have problems setting it up.
    – user128998
    Dec 10 '18 at 20:07
2

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

2

Just spent quite a bit of time researching how to perform this stuff via Terminal one-liners, and, this is what I came up with.

  1. You still need to disable SIP (boot into Recovery Mode by pressing CMD+R at boot, opening Terminal there (from the Utilities Tab at the top) and running csrutil disable and then reboot)
  2. Back in the main os, the file of interest is at /System/Library/LaunchDaemons/com.apple.backupd-helper.plist enter image description here

  3. To modify, for example, the Interval value (from default of 1h=3600 to 2h=7200), you would run

/usr/libexec/PlistBuddy -c "Set :LaunchEvents:com.apple.xpc.activity:com.apple.backupd-auto:Interval 7200" /System/Library/LaunchDaemons/com.apple.backupd-helper.plist

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .