Help with Progress Bar when Time Machine backup is started

I would like to display the progress of the Time Machine backup (red action) with the KM Progress Bar after starting it.

Can anyone help me?

Time Machine <C220 220223T232614>.kmmacros (48,5 KB)

Your shell command

tmutil start backup --block

won't return control to the next KM action until the TM backup has finished - that's what the --block switch does. So first - start a backup but omit the block switch.

Then if you use this command while a backup is underway:

tmutil status

it returns information something like this:

Backup session status:
{
    BackupPhase = Copying;
    ClientID = "com.apple.backupd";
    DateOfStateChange = "2022-02-23 23:12:04 +0000";
    DestinationID = "52DE7DB8-5CDC-416E-A3A3-A0152EE187B5";
    DestinationMountPoint = "/Volumes/Time Machine Backup";
    Percent = "0.5158850747852126";
    Progress =     {
        TimeRemaining = 158;
        "_raw_totalBytes" = 5454922918;
        bytes = 3126792575;
        files = 22176;
        totalBytes = 6000415209;
        totalFiles = 22176;
    };
    Running = 1;
    Stopping = 0;
    "_raw_Percent" = "0.5732056386502362";
}

Put this command inside a set of looping KM actions might enable you to construct the necessary logic to display a progress bar.

I can't be more helpful as I'm somewhat busy right now...

KM 0 2022-02-23_23-20-03

2 Likes

If such a utility existed, I think I would like to use it myself. But I don't think it can exist. The Time Machine app does write data to a log, and it should be possible for KM to read the log and get some information from there.

But how would KM determine how much time is left in the backup? Even in terms of percentage? I don't think even the Time Machine App knows how much "time is left." Is there an option in the tmutil parameters that lets you see how much progress has been made? I don't think there can be. There are many things that can put a backup on hold, so that makes the problem even harder to solve.

Nevertheless this is an intriguing problem. That is, the idea of determining how far a specified program has progressed in its work. There may be some apps that can provide the information needed to allow KM to display a progress bar, but I just don't think tmutil can be one of them.

I found this command online which retrieves some Time Machine records from a MacOS log file. If you or we can figure out how to interpret this data in terms of "percent complete", that may be the best hope of solving your problem.

printf '\e[3J' && log show --predicate 'subsystem == "com.apple.TimeMachine"' --info --last 6h | grep -F 'eMac' | grep -Fv 'etat' | awk -F']' '{print substr($0,1,19), $NF}'

From here:

https://discussions.apple.com/thread/250226175

If you don't need to know percent complete, then there might be a way. Your original question did not say you needed to know the percent complete. You could probably make the KM Progress Bar "bounce back and forth" while the kmutil program is running. Maybe that's all you need?

Bear in mind that I'm not the final answer on any problem in MacOS. Maybe someone else can come up with another idea that could work. For example, maybe the MacOS Time Machine app has AppleScript dictionary support which reports how far it has left to go.

EDIT: @tiffle has a post which may indeed provide the tools you need. I didn't see his post until after I wrote my post. Let me read his post now.

1 Like

My Mac produces this result:

tmutil status
Backup session status:
{
ClientID = "com.apple.backupd";
Percent = 1;
Running = 0;
}

I'm not sure if "Percent=" represents the number what we need in this case. It's also odd that the value is quoted in your result, but unquoted in my result. Its also odd that my value is "1" when I don't even use Time Machine. I would expect it to be 0 or 100 if Time Machine is not running.

I'd be happy to write a utility that converts this value into a KM Progress Bar. Give me ten minutes.

1 Like

When TM is not running (signified by the Running = 0 line) that's the output you get from the command.

I suspect the percent of 1 actually means 100%.

The calculation

bytes / _raw_totalBytes

results in the value shown as _raw_Percent

1 Like

Fair point. I'm just testing my macro now. Here it is. I didn't thoroughly test it because I don't use Time Machine. Give it a try. If it doesn't work, I can fix it. NOTE: I have it triggered every 6 seconds by a clock. If that's not how you want to use this macro, we can change the trigger. It seemed like a decent trigger to me. Of course, KM provides only one Completion Bar so if you have other macros that use this feature, you may find a conflict.

Time Machine Completion Bar Macro (v10.0.2)

Time Machine Completion Bar.kmmacros (6.5 KB)

2 Likes

Hilariously, ten minutes after writing my macro, the completion window popped up because indeed I do have Time Machine running, and I didn't even know I was using it until now. My macro seems to be working correctly. Although now that I look at it, I'm not sure if my macro chose the correct percent line. Here's what my data currently shows:

Backup session status:
{
BackupPhase = Copying;
ClientID = "com.apple.backupd";
DateOfStateChange = "2022-02-24 00:24:40 +0000";
DestinationID = "140xxCB9-4B9F-462D-9599-442xxxxxxxx75";
DestinationMountPoint = "/Volumes/Backups of xxxxxxxxxxxxx";
EventFractionOfTotalProgressBar = "0.1";
Progress = {
Percent = "0.5233334656187151";
TimeRemaining = "985.8886288872275";
"_raw_Percent" = "0.5233334656187151";
"_raw_totalBytes" = 189966503936;
bytes = 378601472;
files = 1124;
sizingFreePreflight = 1;
totalBytes = 189966503936;
totalFiles = 762556;
};
Running = 1;
Stopping = 0;
}

1 Like

After doing some more digging it looks like

bytes = number of bytes copied so far by TM
files = number of files copied so far by TM
totalBytes = total size in bytes of the backup
toalFiles = total number of files in the backup

I found this info here:

2 Likes

Those could be useful, but my macro ran on its own in the last half hour and seemed to work fine using the Percent string.

@Sleepy & @tiffle thank you for your help :+1:

@Sleepy Your macro works great. I have macro included in my backup (enable/disable) because my backup only starts when I connect my external hard drive. Here is an example:

Video

Time Machine Macros <Multi 220224T114008>.kmmacros (78,2 KB)

Click to show image

Another possibility would be the display via an xBar plug-in. Here is an example as well:

Video

Time Machine <C220 220224T114323>.kmmacros (51,0 KB)

Click to show image

I will now include the xBar plug-in as well as your Progress Bar macro. Double is better.
:wink:

1 Like