Skip to content

Instantly share code, notes, and snippets.

@ypujante
Created Sep 18, 2020
Embed
What would you like to do?
Display TimeMachine logs (acts like tail -f)
#!/usr/bin/env bash
# Usage: tm-log.sh [last]
# last: displays up to "last" events before streaming. defaults to 1h (see --last option for log)
LAST=${1:-1h}
ARGS=( --info --predicate 'processImagePath contains "backupd" and subsystem beginswith "com.apple.TimeMachine"' )
# Implementation note: tr -u and sed -l are required (nothing shown until buffer full otherwise!)
tmlog() {
/usr/bin/log "$@" "${ARGS[@]}" | tr -u -s ' ' | sed -l -n 's/com.apple.TimeMachine://gp' | cut -d' ' -f 1,2,10-
}
tmlog show --last $LAST
tmlog stream
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment