The Time Machine control panel gives information on in-progress backups. For example
Is there a way to get the information from the command line?
Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.
Sign up to join this communityThe Time Machine control panel gives information on in-progress backups. For example
Is there a way to get the information from the command line?
While the backup is running, detailed information gan be gained by
tmutil status
which should return something like this:
Backup session status:
{
BackupPhase = Copying;
ClientID = "com.apple.backupd";
DateOfStateChange = "2014-12-18 14:14:21 +0000";
DestinationID = "B4AF88-5AD5-49BE-B254-650B44E20499";
DestinationMountPoint = "/Volumes/TimeMachine";
Percent = "0.852581430477103";
Progress = {
TimeRemaining = 0;
"_raw_totalBytes" = 38596759;
bytes = 36563200;
files = 480;
totalBytes = 42456434;
totalFiles = 480;
};
Running = 1;
Stopping = 0;
"_raw_Percent" = "0.9473127005301144";
}
If you only care for the percentage, try the following (looks ugly, works only if there is a percentage to display):
tmutil status | awk '/_raw_Percent/ {print $3}' | grep -o '[0-9].[0-9]\+\(e-[0-9]\+\)\?' | awk '{print $1*100}'
tmutil
?
status
, running tmutil help status
now returns *** status is a private verb. ***
; why this is the case and especially if this was the case two years ago, I don't know :D
tmutil
? It's not quite JSON. Is it some kind of C object dump?
Jan 27, 2018 at 16:44
jq
which understands JSON to extract information might be a better approach.
Oct 28, 2020 at 11:59
To get only the percentage value:
tmutil status | LC_NUMERIC="C" awk -F'"' '/_raw_Percent/ {print $4 * 100}'
I managed to make a simple script from the accepted answer.
tmstatus () {
eval $(tmutil status | grep -E '[^}];$' | perl -p -e 's/^\s+[\"]*//g;' -e 's/[\"]*\s+\=\s+/=/g') || (echo "Something get wrong..." && return 1)
if [[ $Running -eq 1 ]]
then
export LC_NUMERIC="en_US.UTF-8"
[[ $BackupPhase == "Copying" ]] && Percent=$(printf '%0.2f%%' `bc <<< $Percent*100`) && echo "${DateOfStateChange} ${BackupPhase} backup to ${DestinationMountPoint}: ${totalFiles} files - ${Percent} (~$((${TimeRemaining:-0}/60)) min." || echo "${DateOfStateChange} ${BackupPhase} (Destination ${DestinationID})."
else
echo "TimeMachine backup is not running."
fi
}
I used @Atika's very helpful script but sometimes got errors like bash: 26520.80484282512/60: syntax error: invalid arithmetic operator (error token is ".80484282512/60")
so I made a slight tweak to pass that division operation to bc
and now it works reliably (caveat: for me!):
BEFORE: (~$((${TimeRemaining:-0}/60)) min."
AFTER: (~$(bc <<< ${TimeRemaining:-0}/60) min.)
Updated Script:
tmstatus () {
eval $(tmutil status | grep -E '[^}];$' | perl -p -e 's/^\s+[\"]*//g;' -e 's/[\"]*\s+\=\s+/=/g') || (echo "Something get wrong..." && return 1)
if [[ $Running -eq 1 ]]
then
export LC_NUMERIC="en_US.UTF-8"
[[ $BackupPhase == "Copying" ]] && Percent=$(printf '%0.2f%%' $(bc <<< $Percent*100)) && echo "${DateOfStateChange} ${BackupPhase} backup to ${DestinationMountPoint}: ${totalFiles} files - ${Percent} (~$(bc <<< ${TimeRemaining:-0}/60) min.)" || echo "${DateOfStateChange} ${BackupPhase} (Destination ${DestinationID})."
else
echo "TimeMachine backup is not running."
fi
}